Main Page   Modules   Alphabetical List   Data Structures   File List   Data Fields   Globals  

File Management Wrappers

Cross-platform file management wrappers. More...


Files

file  Files.c
 Linux-specific code for the File Management Wrappers.

file  Files.h
 File management declarations.

file  FilesSpecific.h
 Linux-specific declarations for the File Management Wrappers.


Data Structures

struct  ANetFile
 A cross-platform file identifier. More...


Functions

ANetFile ANetInitFile ()
 Initializes an ANetFile structure. More...

UInt32 ANetGetSetFilePath (ANetFile *f, ANetMemoryTag path, UInt8 set)
 Gets or sets the file path of an ANetFile. More...

UInt32 ANetGetSetFileAsync (ANetFile *f, UInt8 *async, UInt8 set)
 Gets or sets the asynchronous flag of an ANetFile. More...

UInt8 ANetIsFileBusy (ANetFile *f)
 Returns the value of the "busy"flag of an ANetFile. More...

UInt32 ANetGetFileSize (ANetFile *f, UInt32 *size)
 Gets the size of a file pointed by an ANetFile. More...

UInt32 ANetOpenFile (ANetFile *f)
 Opens a file pointed by an ANetFile. More...

UInt32 ANetCloseFile (ANetFile *f)
 Closes a file pointed by an ANetFile. More...

UInt32 ANetReadFile (ANetFile *f, UInt32 startPos, UInt32 length, ANetMemoryTag buffer, UInt32 *read)
 Reads data from a file pointed bu an ANetFile. More...

UInt32 ANetWriteFile (ANetFile *f, ANetMemoryTag buffer)
 Writes at the end of a file pointed by an ANetFile. More...

UInt32 ANetWriteFileAt (ANetFile *f, ANetMemoryTag buffer, UInt32 pos)
UInt32 ANetDeleteFile (ANetFile *f)
UInt32 ANetCopyFile (ANetFile *source, ANetFile *dest)

Detailed Description

Cross-platform file management wrappers.

Here are the File Management Wrappers. They are "wrapper" functions that allow access to file management functions in a cross-platform way.


Function Documentation

UInt32 ANetCloseFile ANetFile   f
 

Closes a file pointed by an ANetFile.

Parameters:
f  The file to close
Returns:
  • 0: no error
  • 1: can't close the file
  • 60: file is busy ("busy" flag is true)
Closes the file pointed by f that was previously opened by ANetOpenFile(). If the file is set to asynchronous mode (see ANetGetSetFileAsync()), then the function will immediately return and will set the "async" flag to true until the operation is done, when the "async" flag will be set to false again.
See also:
ANetOpenFile() ANetGetSetFileAsync()

Definition at line 164 of file Files.c.

References ANetMemoryTag.

UInt32 ANetCopyFile ANetFile   source,
ANetFile   dest
 

UInt32 ANetDeleteFile ANetFile   f
 

UInt32 ANetGetFileSize ANetFile   f,
UInt32   size
 

Gets the size of a file pointed by an ANetFile.

Parameters:
f  The file
size  A pointer to an unsigned 32 bit value containing the file size, in bytes.
Returns:
  • 0: no error
  • 1: can't get the file size
  • 2: file does not exist
  • 3: invalid pointer for size
  • 60: file is busy ("busy" flag is true)
This function returns in the value pointed by size the size, in bytes, of the file. The file must exists and not be busy to be able to call this function. This function can be also used to know if a file exists at some location.

Definition at line 120 of file Files.c.

UInt32 ANetGetSetFileAsync ANetFile   f,
UInt8   async,
UInt8    set
 

Gets or sets the asynchronous flag of an ANetFile.

Parameters:
f  The file
async  A byte containing the "async" flag value; if 0, the file is used synchronously, otherwise it is used asynchronously.
set  If 0, the value of the "async" flag of the file is put in the byte pointed by async. Otherwise, the value of "async" of the file is set to the value pointed by async.
Returns:
  • 0: No error
  • 1: Invalid pointer for async
  • 60: File is busy ("busy" flag is true).
This function gets or sets the value of the "async" flag of a ANetFile structure. If the "async" flag is true, then all the I/O operations done on the file will be asynchronous. Note that on some operating systems some functions might not support asynchronous I/O.

Definition at line 80 of file Files.c.

UInt32 ANetGetSetFilePath ANetFile   f,
ANetMemoryTag    path,
UInt8    set
 

Gets or sets the file path of an ANetFile.

Parameters:
f  The file
path  A memory block. It contains a NULL terminated string.
set  If 0, the function will put the file's path, as a NULL terminated string, in path. Otherwise, the function will set the file's path to function result.
Returns:
  • 0: No error
  • 1: Can't change path
  • 2: Invalid path
  • 3: path is invalid or not big enough
  • 4: file is open
  • 60: File is busy ("busy" flag is true)
This function will not set or get the file path of the ANetFile structure pointed by f. You cannot change the path of the file while it is open or busy. Also not, all paths are accepted on every operating system, and so it is recommended that you do not go outside the directory that contains the ANet daemon.

Definition at line 44 of file Files.c.

References ANetMemoryTag.

ANetFile ANetInitFile void   
 

Initializes an ANetFile structure.

Returns:
A properly initialized ANetFile structure
See also:
ANetGetSetFilePath() ANetWriteFile()
This function returns a properly ANetFile structure. This does not create any new file; to create a new file, set it's path to the new file's location (with ANetGetSetFilePath()), then write some data in the file (with ANetWriteFile());

Definition at line 32 of file Files.c.

UInt8 ANetIsFileBusy ANetFile   f
 

Returns the value of the "busy"flag of an ANetFile.

Parameters:
f  The file
Returns:
  • 0: the file is not busy
  • 1: the file is busy
This function returns the value of "busy" flag of the file. When the "busy" flag is 1, the file is current busy doing some IO, because it's "async" flag is true (see ANetGetSetFileAsync()) and some IO has not finished.
See also:
ANetGetSetFileAsync()

Definition at line 115 of file Files.c.

UInt32 ANetOpenFile ANetFile   f
 

Opens a file pointed by an ANetFile.

Parameters:
f  The file to open
Returns:
  • 0: no error
  • 1: can't open the file
  • 60: file is busy ("busy" flag is true)
This function opens the file pointed by f. While it is not required to open the file before using any of the following file operations, it is highly recommended that you open the file if you plan to do several operations on it. If the file is set to asynchronous mode (set ANetGetSetFileAsync()), then the function will immediately return and will set the "busy" flag to true, until the operation is done, when the "busy" flag will set to false again.
See also:
ANetGetSetFileAsync()

Definition at line 145 of file Files.c.

UInt32 ANetReadFile ANetFile   f,
UInt32    startPos,
UInt32    length,
ANetMemoryTag    buffer,
UInt32   read
 

Reads data from a file pointed bu an ANetFile.

Parameters:
f  The file to read from
startPos  Starting position of the data to be read. The first possible position in a file is 0.
length  The amount of data to read
buffer  Buffer in which the read data will be put.
read  Pointer to the amount of bytes read.
Returns:
  • 0: No error
  • 1: can't open the file
  • 2: can't close the file after operation
  • 3: can't read from the file
  • 4: file doesn't exist
  • 5: bad value for startPos (startPos >= filesize)
  • 6: bad value for length (startPos + length > filesize)
  • 7: buffer invalid or too small
  • 60: file is busy ("busy" flag is true)
This function reads bytes startPos to endPos - 1 of the file into the buffer. The buffer must be big enough to contain the data that was read. Once the data is read, the value pointed by read will be changed to the number of bytes read into the buffer. If the value of read is smaller than length, then you can safely assume that the file was fully read. If the ANetOpenFile() function was not previously called on the file pointed by f, then this function will open the file before the read operation and close the file after the read operation. Otherwise, this function will not close the file after the read operation. This function does not support files bigger than 2^32 bytes. If the file is set to asynchronous mode (see ANetGetSetFileAsync()), then the function will immediatly return and will set the "async" flag to true until the operation is done, when the "async" flag will be set to false again.

Definition at line 175 of file Files.c.

UInt32 ANetWriteFile ANetFile   f,
ANetMemoryTag    buffer
 

Writes at the end of a file pointed by an ANetFile.

Parameters:
f  The file
buffer  the data to write
Returns:
  • 0: no error
  • 1: can't open the file
  • 2: can't close the file after operation
  • 3: can't write to file
  • 4: buffer is invalid
  • 60: file is busy ("busy" flag is true)
This function writes the bytes in buffer at the end of the file. If the file does not already exist, a new file is created. If you want to write to a new file, use ANetDeleteFile() first. If the file is set to asynchronous mode (see ANetGetSetFileAsync()), then the function will immediatly return and will set the "async" flag to true until the operation is done, when the "async" flag will be set to false again.
See also:
ANetDeleteFile() ANetGetSetFileAsync()

UInt32 ANetWriteFileAt ANetFile   f,
ANetMemoryTag    buffer,
UInt32    pos
 


Generated on Sun Dec 23 15:21:00 2001 for ANet by doxygen 1.2.12 written by Dimitri van Heesch, © 1997-2001

SourceForge
Logo