Main Page | Data Structures | File List | Data Fields | Globals | Related Pages

kio.h File Reference

Input / Output functions. More...

#include "ktypes.h"

Defines

#define k_stdin   k_std_stream (K_ISTDIN)
 Gets a KFILE structure for standard input stream.
#define k_stdout   k_std_stream (K_ISTDOUT)
 Gets a KFILE structure for standard output stream.
#define k_stderr   k_std_stream (K_ISTDERR)
 Gets a KFILE structure for standard error stream.
#define k_fopen(sPath, sMode)   k_fopen_info (sPath, sMode, __K_FILE__, __K_LINE__)
 Opens the file whose name is specified and associates it with a KFILE structure. The operations that are allowed are also specified.
#define k_fmopen(sPath, eMode)   k_fmopen_info (sPath, eMode, __K_FILE__, __K_LINE__)
 Opens the file whose name is specified and associates it with a KFILE structure. The operations that are allowed are also specified.
#define k_fclose(f)
 Closes the file associated with the given KFILE structure.
#define K_NOT_IMPLEMENTED
 K_NOT_IMPLEMENTED. Writes in debug mode in the standard output a warning message that indicates that the current function is not implemented.
#define ktrace   k_debug ("%s : %ld\n", __K_FUNCTION__, __K_LINE__)
 Writes in debug mode to the standard output an execution trace.
#define KFILE_newBuffer()   _KFILE_newBuffer (__K_FILE__, __K_LINE__)
 Creates a buffer represented by a KFILE structure.

Typedefs

typedef _KFILE KFILE
 File stream redefinition.

Enumerations

enum  ESeekMode { K_SEEK_SET = 0, K_SEEK_CUR = 1, K_SEEK_END = 2 }
 Seek modes. More...
enum  EOpenMode {
  K_OPEN_READ = 0x01, K_OPEN_WRITE = 0x02, K_OPEN_READWRITE = 0x03, K_OPEN_BEGIN = 0x10,
  K_OPEN_END = 0x20
}
enum  
 Type of stream: input, error or output.

Functions

KTL_API KFILEk_std_stream (KInt i)
 Gets a KFILE structure for specific streams.
KTL_API KBool k_frename (KCString sOldPath, KCString sNewPath)
 Changes the name of the file or directory If the two strings specify different paths and this is supported by the system, the file is moved to the new location.
KTL_API KBool k_fcopy (KCString sOldPath, KCString sNewPath)
 Copy a file or a directory.
KTL_API KBool k_fremove (KCString sFilePath)
 Deletes the file whose named is specified.
KTL_API KBool k_feof (KFILE *f)
 Checks whether the end of file indicator is set.
KTL_API KFILEk_fopen_info (KCString path, KCString mode, KString sFile, KInt32 iLine)
 Opens the file whose name is specified and associates it with a KFILE structure. The operations that are allowed are also specified.
KTL_API KFILEk_fmopen_info (KCString path, EOpenMode eMode, KString sFile, KInt32 iLine)
 Opens the file whose name is specified and associates it with a KFILE structure. The operations that are allowed are also specified.
KTL_API void k_fclose_info (KFILE *f, KString file, KInt32 line)
 Closes the file associated with the given KFILE structure.
KTL_API KInt32 k_ftell (KFILE *f)
 Returns the current value of the position indicator in the specified file.
KTL_API k_size_t k_fwrite (KCPtr buffer, k_size_t size, k_size_t nmemb, KFILE *f)
 Writes an array of elements each one with a size from the block of memory pointed to the current position in the file.
KTL_API k_size_t k_fread (KPtr buffer, k_size_t size, k_size_t nmemb, KFILE *f)
 Reads an array of elements each one with a size from the file and stores them in the block of memory specified. The position indicator is advanced by the total amount of bytes read.
KTL_API KInt k_fseek (KFILE *f, KInt32 v, ESeekMode mode)
 Sets the position indicator to a new position.
KTL_API KInt k_flush (KFILE *stream)
 If the given file was open for writing and the last input/output operation was an output operation, any unwritten data in the output buffer is written to the file. If the parameter is a null pointer, all open files are flushed. The file remains open after this call.
KTL_API KBool k_mkdir (KCString sPath)
 Creates a directory.
KTL_API void k_print_std (KCString format,...)
 Writes to the standard output a sequence of data formatted as the format parameter specifies.
KTL_API void k_print_err (KCString format,...)
 Writes to the error output a sequence of data formatted as the format parameter specifies.
KTL_API void k_debug (KCString format,...)
 Writes in debug mode to the standard output. This function can write too in the debug file "debug.log" only if the file is open by the mean of the k_open_debug_file() function.
KTL_API void k_close_debug_file ()
 Closes the debug file "debug.log".
KTL_API void k_open_debug_file ()
 Opens the debug file "debug.log".
KTL_API void k_print_mutex ()
 Writes to the standard output the states of the mutex.
KTL_API KBool k_log_open (KString path)
 Opens the debug file specified as a parameter.
KTL_API KBool k_log_print (KCString format,...)
 Writes in a debug file a sequence of data formatted as the format parameter specifies.
KTL_API void k_log_close ()
 Closes a debug file.
KTL_API KInt k_sprintf (KString str, KCString format,...)
 Writes in a string a sequence of data formatted as the format parameters specifies.
KTL_API KInt k_snprintf (KString str, k_size_t size, KCString format,...)
 Writes in a string a sequence of data formatted with both size and format specified.
KTL_API KString k_fgets (KString s, KInt size, KFILE *stream)
 Reads characters from a file and stores them in a string until characters have been read or either a newline or the end of file is reached.
KTL_API KFILE_KFILE_newBuffer (KString file, KInt32 line)
 Creates a buffer represented by a KFILE structure.
KTL_API const KUCharKFILE_getBuffer (KFILE *f, KUInt64 *iBytes)
 Gets the buffer represented by a KFILE structure.


Detailed Description

Input / Output functions.

Version:
KToolLib-1.0
Author:
Fabien Gallot
Date:
18/03/2009
Note:
Copyright © 2008-2010 iKlax Media SAS (www.iklaxmedia.com). All rights reserved.

Define Documentation

#define k_fclose  ) 
 

Value:

if (knull != f) { \ k_fclose_info (f, __K_FILE__, __K_LINE__); \ f = knull; \ }
Closes the file associated with the given KFILE structure.

Parameters:
f the pointer to the KFILE structure to be closed

#define k_fmopen sPath,
eMode   )     k_fmopen_info (sPath, eMode, __K_FILE__, __K_LINE__)
 

Opens the file whose name is specified and associates it with a KFILE structure. The operations that are allowed are also specified.

Parameters:
sPath the name of the file to be opened
eMode the file access mode
Returns:
if the file has been successfully opened, the function will return a pointer to a KFILE structure otherwise a null pointer is returned

#define k_fopen sPath,
sMode   )     k_fopen_info (sPath, sMode, __K_FILE__, __K_LINE__)
 

Opens the file whose name is specified and associates it with a KFILE structure. The operations that are allowed are also specified.

Parameters:
sPath the name of the file to be opened
sMode the file access mode
Returns:
if the file has been successfully opened, the function will return a pointer to a KFILE structure otherwise a null pointer is returned

#define k_stderr   k_std_stream (K_ISTDERR)
 

Gets a KFILE structure for standard error stream.

Returns:
the specific KIFILE structure

knull if the creation of the structure could not be performed

#define k_stdin   k_std_stream (K_ISTDIN)
 

Gets a KFILE structure for standard input stream.

Returns:
the specific KIFILE structure

knull if the creation of the structure could not be performed

#define k_stdout   k_std_stream (K_ISTDOUT)
 

Gets a KFILE structure for standard output stream.

Returns:
the specific KIFILE structure

knull if the creation of the structure could not be performed

 
#define KFILE_newBuffer  )     _KFILE_newBuffer (__K_FILE__, __K_LINE__)
 

Creates a buffer represented by a KFILE structure.

Returns:
the pointer to the KFILE structure


Enumeration Type Documentation

enum EOpenMode
 

Enumeration values:
K_OPEN_READ  Open a file in read mode.
K_OPEN_WRITE  Open a file in write mode.
K_OPEN_READWRITE  Open a file in read/write mode.
K_OPEN_BEGIN  Sets the position indicator at the beginning of the file.
K_OPEN_END  Sets the position indicator at the end of the file.

enum ESeekMode
 

Seek modes.

Enumeration values:
K_SEEK_SET  Sets the position indicator to the beginning of a file.
K_SEEK_CUR  Sets the position indicator to the current position of the file pointer.
K_SEEK_END  Sets the position indicator to the end of the file.


Function Documentation

KTL_API KFILE* _KFILE_newBuffer KString  file,
KInt32  line
 

Creates a buffer represented by a KFILE structure.

Parameters:
file the file name where this function is called
line the line number where this function is called
Returns:
the pointer to the KFILE structure

KTL_API void k_debug KCString  format,
  ...
 

Writes in debug mode to the standard output. This function can write too in the debug file "debug.log" only if the file is open by the mean of the k_open_debug_file() function.

Parameters:
format the string that contains the text to be written to the stream. It can optionally contain embedded format tags that are replaced by the values specified in subsequent additional parameters and formatted as requested. The number of arguments following the format parameters should at least be as much as the number of format tags

KTL_API void k_fclose_info KFILE f,
KString  file,
KInt32  line
 

Closes the file associated with the given KFILE structure.

Parameters:
f the pointer to the KFILE structure to be closed
file the file name where this function is called
line the line number where this function is called

KTL_API KBool k_fcopy KCString  sOldPath,
KCString  sNewPath
 

Copy a file or a directory.

If the two strings specify different paths and this is supported by the system, the file is copy to the new location

Parameters:
sOldPath this string contains the name of the file to be copied. This file must exist and the correct writing permissions should be available
sNewPath this string contains the name of the copied file. This shall not be the name of an existing file
Returns:
ktrue if the file is successfully renamed otherwise kfalse

KTL_API KBool k_feof KFILE f  ) 
 

Checks whether the end of file indicator is set.

Parameters:
f the pointer to a KFILE structure
Returns:
ktrue if the end of file indicator is set otherwise kfalse

KTL_API KString k_fgets KString  s,
KInt  size,
KFILE stream
 

Reads characters from a file and stores them in a string until characters have been read or either a newline or the end of file is reached.

Parameters:
s the string where the characters read are stored
size the maximum number of characters to be read
stream the pointer to a KFILE structure
Returns:
the same string as s if successful otherwise a null pointer

KTL_API KInt k_flush KFILE stream  ) 
 

If the given file was open for writing and the last input/output operation was an output operation, any unwritten data in the output buffer is written to the file. If the parameter is a null pointer, all open files are flushed. The file remains open after this call.

Parameters:
stream the pointer to a KFILE structure
Returns:
0 if successful otherwise -1 is returned

KTL_API KFILE* k_fmopen_info KCString  path,
EOpenMode  eMode,
KString  sFile,
KInt32  iLine
 

Opens the file whose name is specified and associates it with a KFILE structure. The operations that are allowed are also specified.

Parameters:
path the name of the file to be opened
eMode the file access mode
sFile the file name where this function is called
iLine the line number where this function is called
Returns:
if the file has been successfully opened, the function will return a pointer to a KFILE structure otherwise a null pointer is returned

KTL_API KFILE* k_fopen_info KCString  path,
KCString  mode,
KString  sFile,
KInt32  iLine
 

Opens the file whose name is specified and associates it with a KFILE structure. The operations that are allowed are also specified.

Parameters:
path the name of the file to be opened
mode the file access mode
sFile the file name where this function is called
iLine the line number where this function is called
Returns:
if the file has been successfully opened, the function will return a pointer to a KFILE structure otherwise a null pointer is returned

KTL_API k_size_t k_fread KPtr  buffer,
k_size_t  size,
k_size_t  nmemb,
KFILE f
 

Reads an array of elements each one with a size from the file and stores them in the block of memory specified. The position indicator is advanced by the total amount of bytes read.

Parameters:
buffer the pointer to a block of memory with a minimum size of size*nmemb bytes
size the size in bytes of each element to be read
nmemb number of elements
f the pointer to the KFILE structure
Returns:
the total number of elements successfully written

KTL_API KBool k_fremove KCString  sFilePath  ) 
 

Deletes the file whose named is specified.

Parameters:
sFilePath the name of the file to be deleted
Returns:
ktrue if the file is successfully deleted otherwise kfalse

KTL_API KBool k_frename KCString  sOldPath,
KCString  sNewPath
 

Changes the name of the file or directory If the two strings specify different paths and this is supported by the system, the file is moved to the new location.

Parameters:
sOldPath this string contains the name of the file to be renamed and/or moved. This file must exist and the correct writing permissions should be available
sNewPath this string contains the new name for the file. This shall not be the name of an existing file
Returns:
ktrue if the file is successfully renamed otherwise kfalse

KTL_API KInt k_fseek KFILE f,
KInt32  v,
ESeekMode  mode
 

Sets the position indicator to a new position.

Parameters:
f the pointer to a KFILE structure
v the number of bytes to offset from position
mode the mode defines the position from where v is added
Returns:
0 if successful otherwise returns a non-zero value

KTL_API KInt32 k_ftell KFILE f  ) 
 

Returns the current value of the position indicator in the specified file.

Parameters:
f the pointer to the KFILE structure
Returns:
the current value of the position indicator otherwise -1

KTL_API k_size_t k_fwrite KCPtr  buffer,
k_size_t  size,
k_size_t  nmemb,
KFILE f
 

Writes an array of elements each one with a size from the block of memory pointed to the current position in the file.

Parameters:
buffer the pointer to the array of elements to be written
size the size in bytes of each element to be written
nmemb number of elements
f the pointer to the KFILE structure
Returns:
the total number of elements successfully written

KTL_API KBool k_log_open KString  path  ) 
 

Opens the debug file specified as a parameter.

Parameters:
path the name of the debug file
Returns:
ktrue if the opening is successful otherwise kfalse

KTL_API KBool k_log_print KCString  format,
  ...
 

Writes in a debug file a sequence of data formatted as the format parameter specifies.

Parameters:
format the string that contains the text to be written to the stream. It can optionally contain embedded format tags that are replaced by the values specified in subsequent additional parameters and formatted as requested. The number of arguments following the format parameters should at least be as much as the number of format tags
Returns:
ktrue if the writing is successful otherwise kfalse

KTL_API KBool k_mkdir KCString  sPath  ) 
 

Creates a directory.

Parameters:
sPath the directory path and name
Returns:
ktrue if the creation is successful otherwise kfalse

KTL_API void k_print_err KCString  format,
  ...
 

Writes to the error output a sequence of data formatted as the format parameter specifies.

Parameters:
format the string that contains the text to be written to the stream. It can optionally contain embedded format tags that are replaced by the values specified in subsequent additional parameters and formatted as requested. The number of arguments following the format parameters should at least be as much as the number of format tags

KTL_API void k_print_std KCString  format,
  ...
 

Writes to the standard output a sequence of data formatted as the format parameter specifies.

Parameters:
format the string that contains the text to be written to the stream. It can optionally contain embedded format tags that are replaced by the values specified in subsequent additional parameters and formatted as requested. The number of arguments following the format parameters should at least be as much as the number of format tags

KTL_API KInt k_snprintf KString  str,
k_size_t  size,
KCString  format,
  ...
 

Writes in a string a sequence of data formatted with both size and format specified.

Parameters:
str the string in which data was written
size the size of the data to be written in the string
format the string that contains the text to be written to the stream. It can optionally contain embedded format tags that are replaced by the values specified in subsequent additional parameters and formatted as requested. The number of arguments following the format parameters should at least be as much as the number of format tags
Returns:
the total number of characters written if successful otherwise a negative number

KTL_API KInt k_sprintf KString  str,
KCString  format,
  ...
 

Writes in a string a sequence of data formatted as the format parameters specifies.

Parameters:
str the string in which data was written
format the string that contains the text to be written to the stream. It can optionally contain embedded format tags that are replaced by the values specified in subsequent additional parameters and formatted as requested. The number of arguments following the format parameters should at least be as much as the number of format tags
Returns:
the total number of characters written if successful otherwise a negative number

KTL_API KFILE* k_std_stream KInt  i  ) 
 

Gets a KFILE structure for specific streams.

Parameters:
i specifies the type of stream desired for the KFILE structure
Returns:
the specific KIFILE structure

knull if the creation of the structure could not be performed

KTL_API const KUChar* KFILE_getBuffer KFILE f,
KUInt64 iBytes
 

Gets the buffer represented by a KFILE structure.

Parameters:
f the pointer to the KFILE structure
iBytes the length of the buffer in bytes
Returns:
the pointer to the buffer


Generated on Tue Mar 9 10:49:30 2010 for iKlax Tools Library (KToolLib) by doxygen 1.3.8