|
GATE
C/C++ Framework
|
File and directory access functions. More...
#include "gate/gate_core_api.h"#include "gate/streams.h"#include "gate/strings.h"#include "gate/arrays.h"#include "gate/maps.h"#include "gate/times.h"Macros | |
| #define | GATE_FILE_INVALID ((void*)(gate_intptr_t)-1) |
| special marker for invalid file access handles | |
| #define | GATE_FILE_SEEK_ORIGIN_BEGIN 0 |
| gate_file_seek() starts at beginning of file | |
| #define | GATE_FILE_SEEK_ORIGIN_CURPOS 1 |
| gate_file_seek() starts at current position in file | |
| #define | GATE_FILE_SEEK_ORIGIN_END 2 |
| gate_file_seek() starts at the end of file | |
| #define | GATE_FILE_OPEN_CREATEOWNERRESTRICTED 0x0100 |
| file creation flag to only allow access for the process owner | |
| #define | GATE_FILE_OPEN_CREATEGROUPRESTRICTED 0x0200 |
| file creation flag to only allow access for the process owner or its primary group | |
| #define | GATE_FILE_OPEN_CREATEEXECUTABLE 0x0400 |
| file creation flag to set the executable flag | |
| #define | GATE_FILE_OPEN_CREATEUNRESTRICTED 0x0800 |
| file creation flag to allow access for everyone | |
| #define | GATE_FILE_OPEN_SHARED 0x1000 |
| file creation flag to open the filed in SHARED mode (opposite of exclusive in case of write access) | |
| #define | GATE_FILE_COPY_OVERWRITE 0x0001 |
| #define | GATE_FILE_COPY_IGNORE_ERROR 0x0002 |
| #define | GATE_FILE_COPY_SKIP_EXISTING 0x0004 |
| #define | GATE_FILE_COPY_SKIP_NEWER 0x0008 |
| #define | GATE_FILEENTRY_ATTRIB_READONLY 0x0001 |
| #define | GATE_FILEENTRY_ATTRIB_HIDDEN 0x0002 |
| #define | GATE_FILEENTRY_ATTRIB_SYSTEM 0x0004 |
| #define | GATE_FILEENTRY_ATTRIB_DIRECTORY 0x0010 |
| #define | GATE_FILEENTRY_ATTRIB_ARCHIVE 0x0020 |
| #define | GATE_FILEENTRY_ATTRIB_DEVICE 0x0040 |
| #define | GATE_FILEENTRY_ATTRIB_FILE 0x0080 |
| #define | GATE_FILEENTRY_ATTRIB_TEMP 0x0100 |
| #define | GATE_FILEENTRY_ATTRIB_LINK 0x0200 |
| #define | GATE_FILEENTRY_ATTRIB_ENCRYPTED 0x0400 |
| #define | GATE_FILEENTRY_ATTRIB_COMPRESSED 0x0800 |
| #define | GATE_FILEENTRY_ATTRIB_VOLUME 0x1000 |
| #define | GATE_FILEENTRY_ATTRIB_SPECIAL 0x2000 |
| #define | GATE_FILEENTRY_ACCESS_OWNERREAD 0x0001 |
| #define | GATE_FILEENTRY_ACCESS_OWNERWRITE 0x0002 |
| #define | GATE_FILEENTRY_ACCESS_OWNEREXECUTE 0x0004 |
| #define | GATE_FILEENTRY_ACCESS_GROUPREAD 0x0010 |
| #define | GATE_FILEENTRY_ACCESS_GROUPWRITE 0x0020 |
| #define | GATE_FILEENTRY_ACCESS_GROUPEXECUTE 0x0040 |
| #define | GATE_FILEENTRY_ACCESS_ALLREAD 0x0100 |
| #define | GATE_FILEENTRY_ACCESS_ALLWRITE 0x0200 |
| #define | GATE_FILEENTRY_ACCESS_ALLEXECUTE 0x0400 |
Typedefs | |
| typedef void * | gate_file_t |
| opened file access handle | |
| typedef gate_bool_t(* | gate_file_copy_list_callback) (char const *source_path, char const *dest_path, gate_result_t result, void *user_param) |
Callback function to be invoked for each copied item in gate_file_copy_list. | |
| typedef gate_controlstream_t | gate_filestream_t |
| Filestream object interface (equals gate_controlstream_t) | |
Functions | |
| GATE_CORE_API gate_result_t | gate_file_exists (gate_string_t const *filepath) |
| Tests if the specified path points to an existing file. | |
| GATE_CORE_API gate_result_t | gate_file_copy (gate_string_t const *srcfilepath, gate_string_t const *dstfilepath, gate_enumint_t flags) |
| Creates a copy of the source file at the destination path. | |
| GATE_CORE_API gate_result_t | gate_file_move (gate_string_t const *srcfilepath, gate_string_t const *dstfilepath) |
| Moves a source file to a new destination. | |
| GATE_CORE_API gate_result_t | gate_file_delete (gate_string_t const *filepath) |
| Deletes a file. | |
| GATE_CORE_API gate_result_t | gate_file_create_link (gate_string_t const *targetpath, gate_string_t const *linkfile) |
| Creates a symbolic link for a target file. | |
| GATE_CORE_API gate_result_t | gate_file_real_path (gate_string_t const *relativepath, gate_string_t *absolutepath) |
| Builds an absolute path from a relative file path. | |
| GATE_CORE_API gate_result_t | gate_file_read_link (gate_string_t const *filepath, gate_string_t *realpath) |
| Reads the target real path of symbolic link. | |
| GATE_CORE_API gate_result_t | gate_file_create_hardlink (gate_string_t const *targetfile, gate_string_t const *linkfile) |
| Creates a hard-link (filesystem alias) for a target file. | |
| GATE_CORE_API gate_result_t | gate_file_get_attributes (gate_string_t const *targetpath, gate_enumint_t *attribs, gate_enumint_t *access_bits) |
| Returns attribute flags of a specific file or directory. | |
| GATE_CORE_API gate_result_t | gate_file_set_attributes (gate_string_t const *targetpath, gate_enumint_t attribs, gate_enumint_t attribs_mask, gate_enumint_t access_bits, gate_enumint_t access_mask) |
| Changes attribute flags of a specific file or directory. | |
| GATE_CORE_API gate_result_t | gate_file_get_times (gate_string_t const *targetpath, gate_timestamp_t *modified, gate_timestamp_t *accessed, gate_timestamp_t *created) |
| Retrieves activitiy timestamps from a given file or directory. | |
| GATE_CORE_API gate_result_t | gate_file_set_times (gate_string_t const *targetpath, gate_timestamp_t const *modified, gate_timestamp_t const *accessed, gate_timestamp_t const *created) |
| Changes activitiy timestamps from a given file or directory. | |
| GATE_CORE_API gate_result_t | gate_file_get_size (gate_string_t const *targetfile, gate_int64_t *filesize) |
| Returns the size of a file entry in bytes. | |
| GATE_CORE_API gate_result_t | gate_file_get_owner (gate_string_t const *targetfile, gate_uint32_t *owner_id, gate_string_t *owner_name) |
| Returns owner information of a file or directory. | |
| GATE_CORE_API gate_result_t | gate_file_open (gate_string_t const *filepath, gate_enumint_t open_flags, gate_file_t *filehandle) |
| Opens a file and returns a filehandle to access its contents. | |
| GATE_CORE_API gate_result_t | gate_file_read (gate_file_t filehandle, char *buffer, gate_size_t bufferlength, gate_size_t *bufferused) |
| Reads bytes from an opened file. | |
| GATE_CORE_API gate_result_t | gate_file_write (gate_file_t filehandle, char const *buffer, gate_size_t bufferlength, gate_size_t *written) |
| Writes bytes to an opened file. | |
| GATE_CORE_API gate_result_t | gate_file_flush (gate_file_t filehandle) |
| Flushes all IO buffers of the opened file. | |
| GATE_CORE_API gate_result_t | gate_file_close (gate_file_t filehandle) |
| Closes an opened file. | |
| GATE_CORE_API gate_result_t | gate_file_seek (gate_file_t filehandle, gate_int64_t position, gate_enumint_t origin, gate_int64_t *newposition) |
| Sets the internal read/write pointer of an opened file. | |
| GATE_CORE_API gate_result_t | gate_file_pos (gate_file_t filehandle, gate_int64_t *position) |
| Returns the current absolute position of the internal read/write pointer in the opened file. | |
| GATE_CORE_API gate_result_t | gate_file_size (gate_file_t filehandle, gate_int64_t *size) |
| Returns the current size of the opened file. | |
| GATE_CORE_API gate_result_t | gate_file_lock (gate_file_t filehandle, gate_bool_t wait) |
| Applies a lock operation on an opened file. | |
| GATE_CORE_API gate_result_t | gate_file_truncate (gate_file_t filehandle) |
| Truncates all contents of a file after the current read/write filepointer position. | |
| GATE_CORE_API gate_result_t | gate_file_unlock (gate_file_t filehandle) |
| Unlocks an opened file, that was previously locked by gate_file_lock() | |
| GATE_CORE_API gate_result_t | gate_file_get_content (gate_string_t const *filepath, gate_string_t *content_buffer) |
| Reads the contents of a file into a string. | |
| GATE_CORE_API gate_result_t | gate_file_get_content_buffer (gate_string_t const *filepath, char *content_buffer, gate_size_t *content_buffer_len) |
| Reads the contents of a file into a buffer. | |
| GATE_CORE_API gate_result_t | gate_file_get_content_lines (gate_string_t const *filepath, gate_arraylist_t string_array) |
| Reads the contents of a file line by line into an array of strings. | |
| GATE_CORE_API gate_result_t | gate_file_set_content (gate_string_t const *filepath, gate_string_t const *content_buffer) |
| Writes the contents of a string into a file. | |
| GATE_CORE_API gate_result_t | gate_file_set_content_buffer (gate_string_t const *filepath, char const *content_buffer, gate_size_t content_buffer_len) |
| Writes the contents of a buffer into a file. | |
| GATE_CORE_API gate_result_t | gate_file_set_content_lines (gate_string_t const *filepath, gate_arraylist_t string_array) |
| Writes the contents of an array of lines into a file. | |
| GATE_CORE_API gate_size_t | gate_file_build_path (char *dest, gate_size_t dest_size, char const *path, gate_size_t path_size, char const *subpath, gate_size_t subpath_size) |
| Builds a filesystem path by concatinating two path parts into a buffer. | |
| GATE_CORE_API gate_string_t * | gate_file_build_path_string (gate_string_t *dest, gate_string_t const *path, gate_string_t const *subpath) |
| Builds a filesystem path by concatinating two path parts into a string. | |
| GATE_CORE_API gate_result_t | gate_file_build_path_components (gate_strbuilder_t *builder, char separator, gate_string_t const *component_array, gate_size_t component_array_length) |
| Builds a filesystem path by an array of path components. | |
| GATE_CORE_API gate_result_t | gate_file_extract_path (char const *src_path, gate_size_t src_path_len, char *name_buffer, gate_size_t name_buffer_len, char *parent_buffer, gate_size_t parent_buffer_len) |
| Extracts parent path and subelement path from a source path string. | |
| GATE_CORE_API gate_result_t | gate_file_extract_path_string (gate_string_t const *src_path, gate_string_t *name, gate_string_t *parent) |
| Extracts parent path and subelement path from a source path string. | |
| GATE_CORE_API gate_result_t | gate_file_split_path (gate_string_t const *src_path, gate_string_t *parent_path, gate_string_t *name) |
| Splits a filesystem path into parent directory and entry name. | |
| GATE_CORE_API gate_size_t | gate_file_split_path_components (gate_string_t const *src_path, char separator_char, gate_string_t *out_array, gate_size_t out_array_capacity) |
| Splits a filesystem path into multiple path components. | |
| GATE_CORE_API gate_result_t | gate_file_copy_list (gate_map_t const *path_map, gate_enumint_t flags, gate_file_copy_list_callback callback, void *user_param) |
| Copies files from a gate_string_t map where key is the source path and value the destination path. | |
| GATE_CORE_API gate_result_t | gate_file_openstream (gate_string_t const *filepath, gate_enumint_t flags, gate_filestream_t **ptrtostreamptr) |
| Opens a file and respresents it as a stream object. | |
Variables | |
| GATE_CORE_API char const | gate_file_path_separator_char |
| single directory item separator character | |
| GATE_CORE_API char const *const | gate_file_path_separator |
| directory item separator string | |
File and directory access functions.
| #define GATE_FILE_COPY_OVERWRITE 0x0001 |
overwrites target file, if it already exists, otherwise cancels with error
| #define GATE_FILE_COPY_IGNORE_ERROR 0x0002 |
continue copy operation of folders, if a single file fails, otherwhise cancel
| #define GATE_FILE_COPY_SKIP_EXISTING 0x0004 |
do not copy files that are already existing on the target location
| #define GATE_FILE_COPY_SKIP_NEWER 0x0008 |
do not copy files that are already existing on the target location with a newer modification date
| #define GATE_FILEENTRY_ATTRIB_READONLY 0x0001 |
entry is read-only
| #define GATE_FILEENTRY_ATTRIB_HIDDEN 0x0002 |
entry is marked hidden, should not be displayed in standard UI
| #define GATE_FILEENTRY_ATTRIB_SYSTEM 0x0004 |
entry is part of the system and may be hidden for standard users
| #define GATE_FILEENTRY_ATTRIB_DIRECTORY 0x0010 |
entry is a directory or sub directory
| #define GATE_FILEENTRY_ATTRIB_ARCHIVE 0x0020 |
entry was changed since last backup and should be archived
| #define GATE_FILEENTRY_ATTRIB_DEVICE 0x0040 |
entry represents a device (not a regular file)
| #define GATE_FILEENTRY_ATTRIB_FILE 0x0080 |
entry is a regular file (not a directory or device)
| #define GATE_FILEENTRY_ATTRIB_TEMP 0x0100 |
entry was created for temporary usage will be removed soon
| #define GATE_FILEENTRY_ATTRIB_LINK 0x0200 |
entry is a link to another path location
| #define GATE_FILEENTRY_ATTRIB_ENCRYPTED 0x0400 |
entry is encrypted
| #define GATE_FILEENTRY_ATTRIB_COMPRESSED 0x0800 |
entry is compressed
| #define GATE_FILEENTRY_ATTRIB_VOLUME 0x1000 |
entry is a volume root
| #define GATE_FILEENTRY_ATTRIB_SPECIAL 0x2000 |
entry is a special file (like FIFO or socket)
| #define GATE_FILEENTRY_ACCESS_OWNERREAD 0x0001 |
owner of entry has read access
| #define GATE_FILEENTRY_ACCESS_OWNERWRITE 0x0002 |
owner of entry has write access
| #define GATE_FILEENTRY_ACCESS_OWNEREXECUTE 0x0004 |
owner of entry can execute it
| #define GATE_FILEENTRY_ACCESS_GROUPREAD 0x0010 |
owner group of entry has read access
| #define GATE_FILEENTRY_ACCESS_GROUPWRITE 0x0020 |
owner group of entry has write access
| #define GATE_FILEENTRY_ACCESS_GROUPEXECUTE 0x0040 |
owner group of entry can execute it
| #define GATE_FILEENTRY_ACCESS_ALLREAD 0x0100 |
everyone has read access
| #define GATE_FILEENTRY_ACCESS_ALLWRITE 0x0200 |
everyone has write access
| #define GATE_FILEENTRY_ACCESS_ALLEXECUTE 0x0400 |
everyone can execute entry
| typedef gate_bool_t(* gate_file_copy_list_callback) (char const *source_path, char const *dest_path, gate_result_t result, void *user_param) |
Callback function to be invoked for each copied item in gate_file_copy_list.
| source_path | Path of source file that was copied |
| dest_path | Path of destination file that contains copied content |
| result | GATE_RESULT_* result code of last copy operation |
| user_param | User-defined parameter |
true continues copying, false cancels further copy operations | GATE_CORE_API gate_result_t gate_file_exists | ( | gate_string_t const * | filepath | ) |
Tests if the specified path points to an existing file.
| filepath | path of file to be tested |
| GATE_CORE_API gate_result_t gate_file_copy | ( | gate_string_t const * | srcfilepath, |
| gate_string_t const * | dstfilepath, | ||
| gate_enumint_t | flags ) |
Creates a copy of the source file at the destination path.
| srcfilepath | path of source file to be copied |
| dstfilepath | path of destination file to be created |
| flags | A combination of GATE_FILE_COPY_* flags |
| GATE_CORE_API gate_result_t gate_file_move | ( | gate_string_t const * | srcfilepath, |
| gate_string_t const * | dstfilepath ) |
Moves a source file to a new destination.
| srcfilepath | path of source file to be movied |
| dstfilepath | path of destination location where the file is moved |
| GATE_CORE_API gate_result_t gate_file_delete | ( | gate_string_t const * | filepath | ) |
Deletes a file.
| filepath | path of file to be deleted |
| GATE_CORE_API gate_result_t gate_file_create_link | ( | gate_string_t const * | targetpath, |
| gate_string_t const * | linkfile ) |
Creates a symbolic link for a target file.
| [in] | targetpath | path of file that is going to be linked |
| [in] | linkfile | path of symbolic link to be created |
| GATE_CORE_API gate_result_t gate_file_real_path | ( | gate_string_t const * | relativepath, |
| gate_string_t * | absolutepath ) |
Builds an absolute path from a relative file path.
| relativepath | relative file path to be resolved |
| absolutepath | output string that is initialized with the generated absolute path |
| GATE_CORE_API gate_result_t gate_file_read_link | ( | gate_string_t const * | filepath, |
| gate_string_t * | realpath ) |
Reads the target real path of symbolic link.
| filepath | path of symbolic link file |
| realpath | output string that is initialized with the real path |
| GATE_CORE_API gate_result_t gate_file_create_hardlink | ( | gate_string_t const * | targetfile, |
| gate_string_t const * | linkfile ) |
Creates a hard-link (filesystem alias) for a target file.
| targetfile | path of file that is going to be linked |
| linkfile | path of symbolic link to be created |
| GATE_CORE_API gate_result_t gate_file_get_attributes | ( | gate_string_t const * | targetpath, |
| gate_enumint_t * | attribs, | ||
| gate_enumint_t * | access_bits ) |
Returns attribute flags of a specific file or directory.
| targetpath | path of file or directory to be accessed |
| attribs | pointer to variable that receives retrieved attribute flags |
| access_bits | pointer to variable that receives retrieved access bits |
| GATE_CORE_API gate_result_t gate_file_set_attributes | ( | gate_string_t const * | targetpath, |
| gate_enumint_t | attribs, | ||
| gate_enumint_t | attribs_mask, | ||
| gate_enumint_t | access_bits, | ||
| gate_enumint_t | access_mask ) |
Changes attribute flags of a specific file or directory.
| targetpath | path of file or directory to be accessed |
| attribs | new attribute bits to be written to the targetpath |
| attribs_mask | bitmask of attributes to written to the targetpath (attributes of non set bits preserve their current value) |
| access_bits | new access bits values to be applied to targetpath |
| access_mask | bitmask of access bits to be updated on targetpath |
| GATE_CORE_API gate_result_t gate_file_get_times | ( | gate_string_t const * | targetpath, |
| gate_timestamp_t * | modified, | ||
| gate_timestamp_t * | accessed, | ||
| gate_timestamp_t * | created ) |
Retrieves activitiy timestamps from a given file or directory.
| targetpath | path of file or directory to be accessed |
| modified | optional pointer to timestamp variable that receives the time of last modification |
| accessed | optional pointer to timestamp variable that receives the time of last access |
| created | optional pointer to timestamp variable that receives the time of creation or update of the filesystem entry |
| GATE_CORE_API gate_result_t gate_file_set_times | ( | gate_string_t const * | targetpath, |
| gate_timestamp_t const * | modified, | ||
| gate_timestamp_t const * | accessed, | ||
| gate_timestamp_t const * | created ) |
Changes activitiy timestamps from a given file or directory.
| targetpath | path of file or directory to be accessed |
| modified | optional pointer to modification timestamp that is written to the filesystem entry |
| accessed | optional pointer to access timestamp variable that is written to the filesystem entry |
| created | optional pointer to entry-creation timestamp variable that is written to the filesystem entry |
| GATE_CORE_API gate_result_t gate_file_get_size | ( | gate_string_t const * | targetfile, |
| gate_int64_t * | filesize ) |
Returns the size of a file entry in bytes.
| targetfile | path of file to be accessed |
| filesize | pointer to variable that receives the actual size |
| GATE_CORE_API gate_result_t gate_file_get_owner | ( | gate_string_t const * | targetfile, |
| gate_uint32_t * | owner_id, | ||
| gate_string_t * | owner_name ) |
Returns owner information of a file or directory.
| [in] | targetfile | path of file to be accessed |
| [out] | owner_id | output pointer to native owner-id |
| [out] | owner_name | output pointer to string to be filled with name of owner account |
| GATE_CORE_API gate_result_t gate_file_open | ( | gate_string_t const * | filepath, |
| gate_enumint_t | open_flags, | ||
| gate_file_t * | filehandle ) |
Opens a file and returns a filehandle to access its contents.
| [in] | filepath | path of file to be accessed |
| [in] | open_flags | GATE_STREAM_OPEN_* indicating to access mode of the file |
| [out] | filehandle | output pointer to filehandle to be used in further calls |
| GATE_CORE_API gate_result_t gate_file_read | ( | gate_file_t | filehandle, |
| char * | buffer, | ||
| gate_size_t | bufferlength, | ||
| gate_size_t * | bufferused ) |
Reads bytes from an opened file.
| [in] | filehandle | Handle to opened file |
| [in] | buffer | Buffer to be filled with read bytes |
| [in] | bufferlength | Capacity of buffer |
| [out] | bufferused | Output pointer receiving the amount of bytes from buffer that were filled |
| GATE_CORE_API gate_result_t gate_file_write | ( | gate_file_t | filehandle, |
| char const * | buffer, | ||
| gate_size_t | bufferlength, | ||
| gate_size_t * | written ) |
Writes bytes to an opened file.
| [in] | filehandle | Handle to opened file |
| [in] | buffer | Buffer with bytes to be written to file |
| [in] | bufferlength | Length of buffer in bytes |
| [out] | written | Output pointer receiving the amount of bytes from buffer that were really written to file |
| GATE_CORE_API gate_result_t gate_file_flush | ( | gate_file_t | filehandle | ) |
Flushes all IO buffers of the opened file.
| [in] | filehandle | Handle to opened file |
| GATE_CORE_API gate_result_t gate_file_close | ( | gate_file_t | filehandle | ) |
Closes an opened file.
| [in] | filehandle | Handle to opened file |
| GATE_CORE_API gate_result_t gate_file_seek | ( | gate_file_t | filehandle, |
| gate_int64_t | position, | ||
| gate_enumint_t | origin, | ||
| gate_int64_t * | newposition ) |
Sets the internal read/write pointer of an opened file.
| [in] | filehandle | Handle to opened file |
| [in] | position | Position-update integer to be added file-pointer (based on origin) |
| [in] | origin | GATE_FILE_SEEK_ORIGIN_* flag indicating where to seek operation should start |
| [out] | newposition | Optional pointer that receives the final absolute position, that filepointer is pointing to |
| GATE_CORE_API gate_result_t gate_file_pos | ( | gate_file_t | filehandle, |
| gate_int64_t * | position ) |
Returns the current absolute position of the internal read/write pointer in the opened file.
| [in] | filehandle | Handle to opened file |
| [out] | position | Output variable that receives the absolute position in bytes |
| GATE_CORE_API gate_result_t gate_file_size | ( | gate_file_t | filehandle, |
| gate_int64_t * | size ) |
Returns the current size of the opened file.
| [in] | filehandle | Handle to opened file |
| [out] | size | Pointer that receives the current filesize in bytes |
| GATE_CORE_API gate_result_t gate_file_lock | ( | gate_file_t | filehandle, |
| gate_bool_t | wait ) |
Applies a lock operation on an opened file.
| [in] | filehandle | Handle to opened file |
| [in] | wait | if "true" the function blocks until the lock can be applied, otherwise it returns an error if the file was already locked |
| GATE_CORE_API gate_result_t gate_file_truncate | ( | gate_file_t | filehandle | ) |
Truncates all contents of a file after the current read/write filepointer position.
| [in] | filehandle | Handle to opened file |
| GATE_CORE_API gate_result_t gate_file_unlock | ( | gate_file_t | filehandle | ) |
Unlocks an opened file, that was previously locked by gate_file_lock()
| [in] | filehandle | Handle to opened file |
| GATE_CORE_API gate_result_t gate_file_get_content | ( | gate_string_t const * | filepath, |
| gate_string_t * | content_buffer ) |
Reads the contents of a file into a string.
| [in] | filepath | Filesystem path of file to be read |
| [out] | content_buffer | Output string initialized with the contents of the opened file |
| GATE_CORE_API gate_result_t gate_file_get_content_buffer | ( | gate_string_t const * | filepath, |
| char * | content_buffer, | ||
| gate_size_t * | content_buffer_len ) |
Reads the contents of a file into a buffer.
| [in] | filepath | Filesystem path of file to be read |
| [out] | content_buffer | Pointer to buffer to be filled with read bytes |
| [in,out] | content_buffer_len | Pointer to size of buffer, updated with finally read bytes |
| GATE_CORE_API gate_result_t gate_file_get_content_lines | ( | gate_string_t const * | filepath, |
| gate_arraylist_t | string_array ) |
Reads the contents of a file line by line into an array of strings.
| [in] | filepath | Filesystem path of file to be read |
| [in] | string_array | Allocated arraylist (of type gate_string_t) to be filled with read lines |
| GATE_CORE_API gate_result_t gate_file_set_content | ( | gate_string_t const * | filepath, |
| gate_string_t const * | content_buffer ) |
Writes the contents of a string into a file.
| [in] | filepath | Filesystem path of file to be overwritten |
| [in] | content_buffer | String containing content to be written to file |
| GATE_CORE_API gate_result_t gate_file_set_content_buffer | ( | gate_string_t const * | filepath, |
| char const * | content_buffer, | ||
| gate_size_t | content_buffer_len ) |
Writes the contents of a buffer into a file.
| [in] | filepath | Filesystem path of file to be overwritten |
| [in] | content_buffer | Byte buffer containing data to be written to file |
| [in] | content_buffer_len | Length of content_buffer in bytes |
| GATE_CORE_API gate_result_t gate_file_set_content_lines | ( | gate_string_t const * | filepath, |
| gate_arraylist_t | string_array ) |
Writes the contents of an array of lines into a file.
| [in] | filepath | Filesystem path of file to be overwritten |
| [in] | string_array | Array list of gate_string_t with lines to be written to file |
| GATE_CORE_API gate_size_t gate_file_build_path | ( | char * | dest, |
| gate_size_t | dest_size, | ||
| char const * | path, | ||
| gate_size_t | path_size, | ||
| char const * | subpath, | ||
| gate_size_t | subpath_size ) |
Builds a filesystem path by concatinating two path parts into a buffer.
| [out] | dest | Buffer receiving the final filesystem path |
| [in] | dest_size | Capacity of dest in bytes |
| [in] | path | string buffer with root part of path |
| [in] | path_size | length of string in path in bytes |
| [in] | subpath | string buffer with subelement part of path |
| [in] | subpath_size | length of string in subpath in bytes |
dest | GATE_CORE_API gate_string_t * gate_file_build_path_string | ( | gate_string_t * | dest, |
| gate_string_t const * | path, | ||
| gate_string_t const * | subpath ) |
Builds a filesystem path by concatinating two path parts into a string.
| [out] | dest | String the receives the final filesystem path |
| [in] | path | string with root part of path |
| [in] | subpath | string with subelement of path |
dest in case of success or NULL in case of allocation error | GATE_CORE_API gate_result_t gate_file_build_path_components | ( | gate_strbuilder_t * | builder, |
| char | separator, | ||
| gate_string_t const * | component_array, | ||
| gate_size_t | component_array_length ) |
Builds a filesystem path by an array of path components.
| [in] | builder | allocated string-builder that is filled with path components |
| [in] | separator | path separator character |
| [in] | component_array | pointer to first element in array of gate_string_t containing path components |
| [in] | component_array_length | amount of elements in component_array |
| GATE_CORE_API gate_result_t gate_file_extract_path | ( | char const * | src_path, |
| gate_size_t | src_path_len, | ||
| char * | name_buffer, | ||
| gate_size_t | name_buffer_len, | ||
| char * | parent_buffer, | ||
| gate_size_t | parent_buffer_len ) |
Extracts parent path and subelement path from a source path string.
| [in] | src_path | string with source path to be parsed |
| [in] | src_path_len | length of src_path in bytes |
| [out] | name_buffer | output string buffer to receive name component from src_path |
| [in] | name_buffer_len | capacity of name_buffer |
| [out] | parent_buffer | output string buffer to receive parent component from src_path |
| [in] | parent_buffer_len | capacity of parent_buffer |
| GATE_CORE_API gate_result_t gate_file_extract_path_string | ( | gate_string_t const * | src_path, |
| gate_string_t * | name, | ||
| gate_string_t * | parent ) |
Extracts parent path and subelement path from a source path string.
| [in] | src_path | string with source path to be parsed |
| [out] | name | output string to receive name component from src_path |
| [out] | parent | output string to receive parent component from src_path |
| GATE_CORE_API gate_result_t gate_file_split_path | ( | gate_string_t const * | src_path, |
| gate_string_t * | parent_path, | ||
| gate_string_t * | name ) |
Splits a filesystem path into parent directory and entry name.
| [in] | src_path | Filesystem path to be split |
| [out] | parent_path | Pointer to string to be initialized with partent directory path |
| [out] | name | Pointer to string to be initialized with directory entry name |
| GATE_CORE_API gate_size_t gate_file_split_path_components | ( | gate_string_t const * | src_path, |
| char | separator_char, | ||
| gate_string_t * | out_array, | ||
| gate_size_t | out_array_capacity ) |
Splits a filesystem path into multiple path components.
| [in] | src_path | Filesystem path to be split |
| [in] | separator_char | Path separator character |
| [out] | out_array | Pointer to first item of string array to be initialized with path components |
| [in] | out_array_capacity | Count of items in out_array to be filled with path components |
out_array that were initialized with path components | GATE_CORE_API gate_result_t gate_file_copy_list | ( | gate_map_t const * | path_map, |
| gate_enumint_t | flags, | ||
| gate_file_copy_list_callback | callback, | ||
| void * | user_param ) |
Copies files from a gate_string_t map where key is the source path and value the destination path.
| [in] | path_map | map of gate_string_t->gate_string_t mapping [source_path -> dest_path] |
| [in] | flags | GATE_FILE_COPY_* flag specifying how files are copied |
| [in] | callback | callback function to be called after each single copy operation with its result |
| [in] | user_param | user defined parameter added to each invocation of callback |
| GATE_CORE_API gate_result_t gate_file_openstream | ( | gate_string_t const * | filepath, |
| gate_enumint_t | flags, | ||
| gate_filestream_t ** | ptrtostreamptr ) |
Opens a file and respresents it as a stream object.
| [in] | filepath | Filesystem path to file to be opened |
| [in] | flags | GATE_STREAM_OPEN_* flags |
| [out] | ptrtostreamptr | Pointer to store create file-stream object |