VFOpenFile(W)

C Specification


#include <revolution/vf.h>

typedef void	VFFile;

VFFile* VFOpenFile( const char* path, const char* mode, u32 attr );
VFFile* VFOpenFileW( const VFWchar* path, const VFWchar* mode, u32 attr );

Arguments

path The address storing the path and file name.
Either a full or relative path may be specified.
mode The permitted access mode.
attr Specifies the file attributes. (Not currently used.)
To assure future compatibility, always specify 0.

Return Values

Pointer for the file descriptor.
NULL is returned if the function fails.

You can get details about the error using VFGetLastError.  

Description

Opens a file.
The following access modes can be specified as the string for mode, the second argument.
"r" Opens in read mode.
"w" Opens a blank file in write mode.
When the specified file already exists, the previous file's content is destroyed.
"a" Opens a file in append mode (where writes occur at the end of the file).
If the file doesn't exist, it is created.
"r+" Opens a file in read/write mode.
If the file doesn't exist, an error occurs.
"w+" Opens a blank file in read/write mode.
When the specified file already exists, the previous file's content is destroyed.
"a+" Opens a file in read/append mode.
If the file doesn't exist. it is created.
Specifying NULL for an access mode has the same effect as using "r+".
Note: Although it is possible to re-open files that are already open with modes other that "w" or "w+", the newly opened copy of the file will have a separate descriptor, requiring caution when reading or writing such files.
For example:
If you write a certain file specifying its file descriptor, and then write that same file using a separate descriptor, you may not be able to save data accurately. For this reason, do not attempt to perform read/write operations on the same file using multiple descriptors at the same time. If you do, the accuracy of the data cannot be guaranteed.

See Also

VFCreateFile, VFSeekFile, VFReadFile, VFWriteFile, VFCloseFile, VFDeleteFile

Revision History

2006/06/23
2007/05/08 Added description of Return Values.


CONFIDENTIAL