FileHandle FileCreate( /* sets thread's error value */
const char * name, /* relative to working directory */
FileCreateFlags flags, /* see below */
FileAttrs attributes); /* FileAttrs of new file */
This routine creates a byte file. The file may be a DOS file or a GEOS byte file. If the file is successfully opened,
FileCreate()
will return the file's handle; otherwise, it will return a null handle and set the thread's error value.
The second parameter is a word-length
FileCreateFlags
record. The third parameter,
attributes
, describes the
FileAttrs
record to be set for the new file.
If successful,
FileCreate()
returns the file's handle. If it is unsuccessful, it returns a null handle and sets the thread's error value (accessible via
ThreadGetError()
). The following error values are commonly returned:
FileCreate()
will fail until a file is closed.
FileCreate()
was called with FILE_CREATE_ONLY and a file with the specified name already exists.
FileCreate()
was called with FILE_CREATE_TRUNCATE or FILE_CREATE_NO_TRUNCATE and a file exists in a different format than desired; i.e. you passed FCF_NATIVE and the file already exists in the GEOS format, or vice versa.Examples: An example of usage is shown below.
Example of FileCreate() usage
/* Here we create a DOS file in the current working directory. If the file already * exists, we open the existing file and truncate it. */
FileHandle newFile;
newFile = FileCreate("NEWFILE.TXT",
( (FILE_CREATE_TRUNCATE | FCF_NATIVE)
| (FILE_ACCESS_RW | FILE_DENY_RW)),
0); /* set no attribute bits */
See Also: FileCreateTempFile(),
FileOpen().
Include: file.h
word FileCreateDir( /* Returns error & sets thread's error value */
const char * name); /* Relative path of new directory */
This routine creates a new directory. The parameter is a path string; the path is relative to the current directory. The last element of the path string must be the directory to create.
If
FileCreateDir()
is successful, it returns zero and clears the thread's error value. Otherwise, it returns an error code and sets the thread's error value (accessible via
ThreadGetError()
). The following errors are returned:
FileCreateDir()
to create the directory within a directory which does not exist.
See Also: FileDeleteDir().
Include: file.h
FileHandle FileCreateTempFile( /* Sets thread's error value */
char * dir, /* directory, relative to working dir.;
* file name replaces 14 trailing null
* characters upon return */
FileCreateFlags flags,
FileAttrs attributes);
This routine creates and opens a temporary file in the directory specified. The routine automatically selects a name for the temporary file. No creation flags are needed, since the file will definitely be created anew and will be used only by this geode. The directory string must end with fourteen null bytes (enough to be replaced by the new file's name).
If
FileCreateTempFile()
is successful, it returns the file's handle as well as the string passed in
dir
, with the trailing null characters replaced by the file name. If it is unsuccessful, it returns a null handle and sets the thread's error value to a member of the
FileError
enumerated type. (This error value is accessible via
ThreadGetError()
.)
Tips and Tricks: Temporary files are usually created in a subdirectory of SP_PRIVATE_DATA.
See Also: FileCreate().
Include: file.h
word FileDelete( /* returns error */
const char * name); /* path relative to working directory */
This routine deletes a file. If it is successful, it returns zero; otherwise, it returns a
FileError
. Common errors include:
Include: file.h
GEOS SDK TechDocs
|
|
FatalError() ...
|
FileDeleteDir() ...