This is the documentation for Enlighten.
module File Handling
Classes
Name | Description |
---|---|
Geo::GeoFileManager | The file manager deals with locating resources given a path and a filename. |
Enums
Name | Description |
---|---|
GeoFSeekOrigin | To avoid pulling in the entire stdio header, use our own values for GeoFSeek. |
Typedefs
Name | Description |
---|---|
void(* FileOpenCallback)(const char *path, const char *mode) | path: path to the file being opened. |
__int64 offset_t | A offset type, similar to size_t (off_t is not supported on all used platforms) |
Functions
Name | Description |
---|---|
FileExists(const char *) | Checks that testFile exists. |
FileExistsAndIsNewer(const char *, const char *) | Checks that testFile exists and is newer than exemplarFile. |
FileIsWritable(const char *) | Checks that the file named filename can be written to. |
FreeLoadedFile(void *) | Free a previously loaded file. |
GeoConstructAPIFilename(const char *, char *) | Construct a filename for use in the underlying platform filesystem API. |
GeoDeleteFile(const char *) | Delete a file. |
GeoDirectoryCreate(const char *) | Creates a directory and all the directories leading up to it. |
GeoDirectoryDelete(const char *) | Delete a directory and all its files, without user prompts. |
GeoFClose(FILE *) | A safe alternative to fclose. |
GeoFEof(FILE *) | A safe alternative to feof. |
GeoFError(FILE *) | A safe alternative to ferror. Returns a non-zero value to indicate an error. |
GeoFOpen(const char *, const char *) | GeoFOpen. |
GeoFRead(void *, size_t, size_t, FILE *) | A safe alternative to fread. |
GeoFSeek(offset_t, GeoFSeekOrigin, FILE *) | A safe alternative to fseek. |
GeoFTell(FILE *) | A safe alternative to ftell. |
GeoFWrite(const void *, size_t, size_t, FILE *) | A safe alternative to fwrite. |
GeoRenameFile(const char *, const char *) | Rename a file. |
GetFileSystemPrefix() | Get the previously set file system prefix for the current platform. |
InvokeFileOpenCallback(const char *, const char *) | Invoke the file open callback, if set. |
LoadFile(const char *, u32 &, u32, u32) | A safe alternative to ferror. |
LoadFileStr(const char *, u32 &, u32) | Load a file and append a null terminator. |
SaveFile(const char *, const void *, u32) | Save a file. |
SetFileOpenCallback(FileOpenCallback) | Set the function to be called when a file is opened, or a null pointer to disable the callback. |
SetFileSystemPrefix(const char *) | Set a file system prefix for the current platform. |
GeoFSeekOrigin
public: enum GeoFSeekOrigin
{
GEO_SEEK_SET = 0,
GEO_SEEK_CUR = 1,
GEO_SEEK_END = 2
}
To avoid pulling in the entire stdio header, use our own values for GeoFSeek.
enumerators
GEO_SEEK_SET | Seek from beginning of file (SEEK_SET) |
GEO_SEEK_CUR | Seek from current position (SEEK_CUR) |
GEO_SEEK_END | Seek from end of file (SEEK_END) |
bool GEO_CALL Geo::FileExists
public: bool GEO_CALL FileExists
(
const char * testFile
)
Checks that testFile exists.
bool GEO_CALL Geo::FileExistsAndIsNewer
public: bool GEO_CALL FileExistsAndIsNewer
(
const char * testFile,
const char * exemplarFile
)
Checks that testFile exists and is newer than exemplarFile.
Returns true iff both files exist and the testFile has been modified more recently than exemplarFile.
bool GEO_CALL Geo::FileIsWritable
public: bool GEO_CALL FileIsWritable
(
const char * filename
)
Checks that the file named filename can be written to.
Returns true for a writable existing file, or if a file with that name could be created.
void GEO_CALL Geo::FreeLoadedFile
public: void GEO_CALL FreeLoadedFile
(
void * file
)
Free a previously loaded file.
bool Geo::GeoConstructAPIFilename
public: bool GeoConstructAPIFilename
(
const char * inFilename,
char * outFilename
)
Construct a filename for use in the underlying platform filesystem API.
bool Geo::GeoDeleteFile
public: bool GeoDeleteFile
(
const char * filename
)
Delete a file.
bool GEO_CALL Geo::GeoDirectoryCreate
public: bool GEO_CALL GeoDirectoryCreate
(
const char * directory
)
Creates a directory and all the directories leading up to it.
Used often in the pipeline tools
Note
Does nothing (and returns false) on a console
bool GEO_CALL Geo::GeoDirectoryDelete
public: bool GEO_CALL GeoDirectoryDelete
(
const char * directory
)
Delete a directory and all its files, without user prompts.
Used on occasion in the pipeline tools, though it is dangerous to act like this without user permission!
Note
Does nothing (and returns false) on a console
int GEO_CALL Geo::GeoFClose
public: int GEO_CALL GeoFClose
(
FILE * stream
)
A safe alternative to fclose.
int GEO_CALL Geo::GeoFEof
public: int GEO_CALL GeoFEof
(
FILE * stream
)
A safe alternative to feof.
Geo::s32 GEO_CALL Geo::GeoFError
public: Geo::s32GEO_CALL GeoFError
(
FILE * file
)
A safe alternative to ferror. Returns a non-zero value to indicate an error.
FILE* GEO_CALL Geo::GeoFOpen
public: FILE *GEO_CALL GeoFOpen
(
const char * filename,
const char * mode
)
GeoFOpen.
Calls the operating system's fopen() method, and returns a FILE* in the usual fashion, however it takes account of any local system convension for file paths, and transparently manages these behind the scenes.
size_t GEO_CALL Geo::GeoFRead
public: size_t GEO_CALL GeoFRead
(
void * input,
size_t size,
size_t count,
FILE * file
)
A safe alternative to fread.
This guarantees (unless there is an error) to load the entire data. If the number returned does not match the count specified for input, there was a file IO problem.
int GEO_CALL Geo::GeoFSeek
public: int GEO_CALL GeoFSeek
(
offset_t offset,
GeoFSeekOrigin origin,
FILE * file
)
A safe alternative to fseek.
offset_t GEO_CALL Geo::GeoFTell
public: offset_t GEO_CALL GeoFTell
(
FILE * file
)
A safe alternative to ftell.
size_t GEO_CALL Geo::GeoFWrite
public: size_t GEO_CALL GeoFWrite
(
const void * output,
size_t size,
size_t count,
FILE * file
)
A safe alternative to fwrite.
bool GEO_CALL Geo::GeoRenameFile
public: bool GEO_CALL GeoRenameFile
(
const char * oldName,
const char * newName
)
Rename a file.
const char* GEO_CALL Geo::GetFileSystemPrefix
public: const char *GEO_CALL GetFileSystemPrefix()
Get the previously set file system prefix for the current platform.
void Geo::InvokeFileOpenCallback
public: void InvokeFileOpenCallback
(
const char * path,
const char * mode
)
Invoke the file open callback, if set.
void* GEO_CALL Geo::LoadFile
public: void *GEO_CALL LoadFile
(
const char * filename,
u32 & length,
u32 align,
u32 extra_alloc
)
A safe alternative to ferror.
Load a file returns 0 if this fails the loaded file must be freed using FreeLoadedFile
char* GEO_CALL Geo::LoadFileStr
public: char *GEO_CALL LoadFileStr
(
const char * filename,
u32 & length,
u32 align
)
Load a file and append a null terminator.
The loaded file must be freed using FreeLoadedFile.
Returns
Null if this fails
bool GEO_CALL Geo::SaveFile
public: bool GEO_CALL SaveFile
(
const char * filename,
const void * data,
u32 length
)
Save a file.
Returns
False if this fails.
void Geo::SetFileOpenCallback
public: void SetFileOpenCallback
(
FileOpenCallback callback
)
Set the function to be called when a file is opened, or a null pointer to disable the callback.
This has no effect unless GEO_DEVEL is defined!
void GEO_CALL Geo::SetFileSystemPrefix
public: void GEO_CALL SetFileSystemPrefix
(
const char * prefix
)
Set a file system prefix for the current platform.
For example, "/app_home" then GeoFOpen "/filename" will open e.g. "/app_home/filename"