GrafX2 2.9.3227
The ultimate 256-color painting program
|
Low-level endian-neutral file operations, and also some filesystem operations. More...
Macros | |
#define | PATH_SEPARATOR "/" |
default path separator character More... | |
Typedefs | |
typedef void | T_File_dir_cb(void *pdata, const char *filename, const word *unicode_filename, byte is_file, byte is_directory, byte is_hidden) |
Functions | |
int | Read_byte (FILE *file, byte *dest) |
Reads a single byte from an open file. Returns true if OK, false if a file i/o error occurred. More... | |
int | Write_byte (FILE *file, byte b) |
Writes a single byte to an open file. Returns true if OK, false if a file i/o error occurred. More... | |
int | Read_bytes (FILE *file, void *dest, size_t size) |
Reads several bytes from an open file. Returns true if OK, false if a file i/o error occurred. More... | |
int | Read_byte_line (FILE *file, char *line, size_t size) |
int | Write_bytes (FILE *file, const void *dest, size_t size) |
Writes several bytes to an open file. Returns true if OK, false if a file i/o error occurred. More... | |
int | Read_word_le (FILE *file, word *dest) |
Reads a 16-bit Low-Endian word from an open file. Returns true if OK, false if a file i/o error occurred. More... | |
int | Write_word_le (FILE *file, word w) |
Writes a 16-bit Low-Endian word to an open file. Returns true if OK, false if a file i/o error occurred. More... | |
int | Read_dword_le (FILE *file, dword *dest) |
Reads a 32-bit Low-Endian dword from an open file. Returns true if OK, false if a file i/o error occurred. More... | |
int | Write_dword_le (FILE *file, dword dw) |
Writes a 32-bit Low-Endian dword to an open file. Returns true if OK, false if a file i/o error occurred. More... | |
int | Read_word_be (FILE *file, word *dest) |
Reads a 16-bit Big-Endian word from an open file. Returns true if OK, false if a file i/o error occurred. More... | |
int | Write_word_be (FILE *file, word w) |
Writes a 16-bit Big-Endian word to an open file. Returns true if OK, false if a file i/o error occurred. More... | |
int | Read_dword_be (FILE *file, dword *dest) |
Reads a 32-bit Big-Endian dword from an open file. Returns true if OK, false if a file i/o error occurred. More... | |
int | Write_dword_be (FILE *file, dword dw) |
Writes a 32-bit Big-Endian dword to an open file. Returns true if OK, false if a file i/o error occurred. More... | |
unsigned long | File_length_file (FILE *file) |
Size of an open file, in bytes. More... | |
char * | Filepath_append_to_dir (const char *dir, const char *filename) |
Construct full file path. More... | |
char * | Extract_filename (const char *source) |
Extracts the filename part from a full file name. More... | |
char * | Extract_path (const char *source) |
Extracts the directory from a full file name. More... | |
char * | Find_last_separator (const char *str) |
Finds the rightmost path separator in a full filename. Used to separate directory from file. More... | |
word * | Find_last_separator_unicode (const word *str) |
Finds the rightmost path separator in a full filename in unicode. Used to separate directory from file. More... | |
int | Position_last_dot (const char *fname) |
finds the rightmost '.' character in fullname. Used to find file extension. returns -1 if not found More... | |
int | Position_last_dot_unicode (const word *fname) |
finds the rightmost '.' character in fullname. Used to find file extension. returns -1 if not found More... | |
unsigned long | File_length (const char *fname) |
Size of a file, in bytes. Returns 0 in case of error. More... | |
int | File_exists (const char *fname) |
Returns true if a file passed as a parameter exists in the current directory. More... | |
int | Directory_exists (const char *directory) |
Returns true if a directory passed as a parameter exists in the current directory. More... | |
int | Directory_create (const char *directory) |
Creates a directory. More... | |
int | File_is_hidden (const char *fname, const char *full_name) |
Check if a file or directory is hidden. Full name (with directories) is optional. More... | |
void | For_each_file (const char *directory_name, void Callback(const char *full_name, const char *file_name)) |
Scans a directory, calls Callback for each file in it,. More... | |
void | For_each_directory_entry (const char *directory_name, void *pdata, T_File_dir_cb Callback) |
Scans a directory, calls Callback for each file or directory in it,. More... | |
word * | Get_Unicode_Filename (word *filename_unicode, const char *filename, const char *directory) |
Convert a file name to unicode characters. More... | |
void | Append_path (char *path, const char *filename, char *reverse_path) |
Appends a file or directory name to an existing directory name. More... | |
byte | Create_lock_file (const char *file_directory) |
Creates a lock file, to check if an other instance of Grafx2 is running. More... | |
void | Release_lock_file (const char *file_directory) |
Release a lock file created by Create_lock_file. More... | |
char * | Get_current_directory (char *buf, word **unicode, size_t size) |
Return the current directory, equivalent to getcwd() More... | |
int | Change_directory (const char *path) |
Change current directory. return 0 for success, -1 in case of error. More... | |
int | Remove_path (const char *path) |
Remove the file. More... | |
int | Remove_directory (const char *path) |
Remove the directory. More... | |
char * | Calculate_relative_path (const char *ref_path, const char *path) |
Calculate relative path. More... | |
Low-level endian-neutral file operations, and also some filesystem operations.
Many of these may seem trivial, but the wrappers eliminate the need for a forest of preprocessor defines in each file. You MUST use the functions in this file instead of: