GATE
files.h File Reference

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"

Classes

struct  gate_file_properties_class
 
struct  gate_file_entry_class
 
struct  gate_file_filter_class
 
struct  gate_file_dirreader_class
 

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_OWNERSETID   0x0008
 
#define GATE_FILEENTRY_ACCESS_GROUPREAD   0x0010
 
#define GATE_FILEENTRY_ACCESS_GROUPWRITE   0x0020
 
#define GATE_FILEENTRY_ACCESS_GROUPEXECUTE   0x0040
 
#define GATE_FILEENTRY_ACCESS_GROUPSETID   0x0080
 
#define GATE_FILEENTRY_ACCESS_ALLREAD   0x0100
 
#define GATE_FILEENTRY_ACCESS_ALLWRITE   0x0200
 
#define GATE_FILEENTRY_ACCESS_ALLEXECUTE   0x0400
 
#define GATE_FILEENTRY_ACCESS_NODELETE   0x0800
 

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)
 
typedef struct gate_file_properties_class gate_file_properties_t
 
typedef struct gate_file_entry_class gate_file_entry_t
 
typedef struct gate_file_filter_class gate_file_filter_t
 
typedef gate_bool_t(* gate_file_list_callback_t) (gate_file_entry_t const *entry, void *userparam)
 
typedef struct gate_file_dirreader_class gate_file_dirreader_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_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 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_tgate_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.
 
GATE_CORE_API gate_result_t gate_file_root_list (gate_file_list_callback_t callback, void *userparam)
 
GATE_CORE_API gate_result_t gate_file_list (gate_string_t const *dirpath, gate_file_list_callback_t callback, void *userparam)
 
GATE_CORE_API gate_result_t gate_file_find (gate_string_t const *dirpath, gate_file_filter_t const *filter, gate_file_list_callback_t callback, void *userparam)
 
GATE_CORE_API gate_result_t gate_file_get_entry (gate_string_t const *filepath, gate_file_entry_t *ptrtonewentry)
 
GATE_CORE_API gate_result_t gate_file_dir_create (gate_string_t const *dirpath)
 
GATE_CORE_API gate_result_t gate_file_dir_create_all (gate_string_t const *dirpath)
 
GATE_CORE_API gate_result_t gate_file_dir_delete (gate_string_t const *dirpath)
 
GATE_CORE_API gate_result_t gate_file_dir_delete_recursive (gate_string_t const *dirpath)
 
GATE_CORE_API gate_result_t gate_file_dir_exists (gate_string_t const *dirpath)
 
GATE_CORE_API gate_result_t gate_file_dir_open (gate_string_t const *dirpath, gate_file_dirreader_t *dirhandle)
 
GATE_CORE_API gate_size_t gate_file_dir_read (gate_file_dirreader_t *dirhandle, char *path, gate_size_t pathlen, gate_bool_t filename_only)
 
GATE_CORE_API gate_result_t gate_file_dir_close (gate_file_dirreader_t *dirhandle)
 

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
 

Detailed Description

File and directory access functions.

Macro Definition Documentation

◆ GATE_FILE_COPY_IGNORE_ERROR

#define GATE_FILE_COPY_IGNORE_ERROR   0x0002

continue copy operation of folders, if a single file fails, otherwhise cancel

◆ GATE_FILE_COPY_OVERWRITE

#define GATE_FILE_COPY_OVERWRITE   0x0001

overwrites target file, if it already exists, otherwise cancels with error

◆ GATE_FILE_COPY_SKIP_EXISTING

#define GATE_FILE_COPY_SKIP_EXISTING   0x0004

do not copy files that are already existing on the target location

◆ GATE_FILE_COPY_SKIP_NEWER

#define GATE_FILE_COPY_SKIP_NEWER   0x0008

do not copy files that are already existing on the target location with a newer modification date

◆ GATE_FILEENTRY_ACCESS_ALLEXECUTE

#define GATE_FILEENTRY_ACCESS_ALLEXECUTE   0x0400

everyone can execute entry

◆ GATE_FILEENTRY_ACCESS_ALLREAD

#define GATE_FILEENTRY_ACCESS_ALLREAD   0x0100

everyone has read access

◆ GATE_FILEENTRY_ACCESS_ALLWRITE

#define GATE_FILEENTRY_ACCESS_ALLWRITE   0x0200

everyone has write access

◆ GATE_FILEENTRY_ACCESS_GROUPEXECUTE

#define GATE_FILEENTRY_ACCESS_GROUPEXECUTE   0x0040

owner group of entry can execute it

◆ GATE_FILEENTRY_ACCESS_GROUPREAD

#define GATE_FILEENTRY_ACCESS_GROUPREAD   0x0010

owner group of entry has read access

◆ GATE_FILEENTRY_ACCESS_GROUPWRITE

#define GATE_FILEENTRY_ACCESS_GROUPWRITE   0x0020

owner group of entry has write access

◆ GATE_FILEENTRY_ACCESS_OWNEREXECUTE

#define GATE_FILEENTRY_ACCESS_OWNEREXECUTE   0x0004

owner of entry can execute it

◆ GATE_FILEENTRY_ACCESS_OWNERREAD

#define GATE_FILEENTRY_ACCESS_OWNERREAD   0x0001

owner of entry has read access

◆ GATE_FILEENTRY_ACCESS_OWNERWRITE

#define GATE_FILEENTRY_ACCESS_OWNERWRITE   0x0002

owner of entry has write access

◆ GATE_FILEENTRY_ATTRIB_ARCHIVE

#define GATE_FILEENTRY_ATTRIB_ARCHIVE   0x0020

entry was changed since last backup and should be archived

◆ GATE_FILEENTRY_ATTRIB_COMPRESSED

#define GATE_FILEENTRY_ATTRIB_COMPRESSED   0x0800

entry is compressed

◆ GATE_FILEENTRY_ATTRIB_DEVICE

#define GATE_FILEENTRY_ATTRIB_DEVICE   0x0040

entry represents a device (not a regular file)

◆ GATE_FILEENTRY_ATTRIB_DIRECTORY

#define GATE_FILEENTRY_ATTRIB_DIRECTORY   0x0010

entry is a directory or sub directory

◆ GATE_FILEENTRY_ATTRIB_ENCRYPTED

#define GATE_FILEENTRY_ATTRIB_ENCRYPTED   0x0400

entry is encrypted

◆ GATE_FILEENTRY_ATTRIB_FILE

#define GATE_FILEENTRY_ATTRIB_FILE   0x0080

entry is a regular file (not a directory or device)

◆ GATE_FILEENTRY_ATTRIB_HIDDEN

#define GATE_FILEENTRY_ATTRIB_HIDDEN   0x0002

entry is marked hidden, should not be displayed in standard UI

◆ GATE_FILEENTRY_ATTRIB_LINK

#define GATE_FILEENTRY_ATTRIB_LINK   0x0200

entry is a link to another path location

◆ GATE_FILEENTRY_ATTRIB_READONLY

#define GATE_FILEENTRY_ATTRIB_READONLY   0x0001

entry is read-only

◆ GATE_FILEENTRY_ATTRIB_SPECIAL

#define GATE_FILEENTRY_ATTRIB_SPECIAL   0x2000

entry is a special file (like FIFO or socket)

◆ GATE_FILEENTRY_ATTRIB_SYSTEM

#define GATE_FILEENTRY_ATTRIB_SYSTEM   0x0004

entry is part of the system and may be hidden for standard users

◆ GATE_FILEENTRY_ATTRIB_TEMP

#define GATE_FILEENTRY_ATTRIB_TEMP   0x0100

entry was created for temporary usage will be removed soon

◆ GATE_FILEENTRY_ATTRIB_VOLUME

#define GATE_FILEENTRY_ATTRIB_VOLUME   0x1000

entry is a volume root

Typedef Documentation

◆ gate_file_copy_list_callback

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.

Parameters
source_pathPath of source file that was copied
dest_pathPath of destination file that contains copied content
resultGATE_RESULT_* result code of last copy operation
user_paramUser-defined parameter
Returns
true continues copying, false cancels further copy operations

Function Documentation

◆ gate_file_build_path()

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.

Parameters
[out]destBuffer receiving the final filesystem path
[in]dest_sizeCapacity of dest in bytes
[in]pathstring buffer with root part of path
[in]path_sizelength of string in path in bytes
[in]subpathstring buffer with subelement part of path
[in]subpath_sizelength of string in subpath in bytes
Returns
amount of bytes written to dest

◆ gate_file_build_path_components()

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.

Parameters
[in]builderallocated string-builder that is filled with path components
[in]separatorpath separator character
[in]component_arraypointer to first element in array of gate_string_t containing path components
[in]component_array_lengthamount of elements in component_array
Returns
GATE_RESULT_* result code

◆ gate_file_build_path_string()

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.

Parameters
[out]destString the receives the final filesystem path
[in]pathstring with root part of path
[in]subpathstring with subelement of path
Returns
Returns dest in case of success or NULL in case of allocation error

◆ gate_file_close()

GATE_CORE_API gate_result_t gate_file_close ( gate_file_t filehandle)

Closes an opened file.

Parameters
[in]filehandleHandle to opened file
Returns
value GATE_RESULT_* code

◆ gate_file_copy()

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.

Parameters
srcfilepathpath of source file to be copied
dstfilepathpath of destination file to be created
flagsA combination of GATE_FILE_COPY_* flags
Returns
value GATE_RESULT_* code

◆ gate_file_copy_list()

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.

Parameters
[in]path_mapmap of gate_string_t->gate_string_t mapping [source_path -> dest_path]
[in]flagsGATE_FILE_COPY_* flag specifying how files are copied
[in]callbackcallback function to be called after each single copy operation with its result
[in]user_paramuser defined parameter added to each invocation of callback
Returns
GATE_RESULT_* result code

◆ gate_file_create_hardlink()

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.

Parameters
targetfilepath of file that is going to be linked
linkfilepath of symbolic link to be created
Returns
value GATE_RESULT_* code

◆ gate_file_create_link()

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.

Parameters
[in]targetpathpath of file that is going to be linked
[in]linkfilepath of symbolic link to be created
Returns
value GATE_RESULT_* code

◆ gate_file_delete()

GATE_CORE_API gate_result_t gate_file_delete ( gate_string_t const * filepath)

Deletes a file.

Parameters
filepathpath of file to be deleted
Returns
value GATE_RESULT_* code

◆ gate_file_exists()

GATE_CORE_API gate_result_t gate_file_exists ( gate_string_t const * filepath)

Tests if the specified path points to an existing file.

Parameters
filepathpath of file to be tested
Returns
value GATE_RESULT_* code, GATE_RESULT_OK indicates that the file exists

◆ gate_file_extract_path()

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.

Parameters
[in]src_pathstring with source path to be parsed
[in]src_path_lenlength of src_path in bytes
[out]name_bufferoutput string buffer to receive name component from src_path
[in]name_buffer_lencapacity of name_buffer
[out]parent_bufferoutput string buffer to receive parent component from src_path
[in]parent_buffer_lencapacity of parent_buffer
Returns
GATE_RESULT_* result code

◆ gate_file_extract_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.

Parameters
[in]src_pathstring with source path to be parsed
[out]nameoutput string to receive name component from src_path
[out]parentoutput string to receive parent component from src_path
Returns
GATE_RESULT_* result code

◆ gate_file_flush()

GATE_CORE_API gate_result_t gate_file_flush ( gate_file_t filehandle)

Flushes all IO buffers of the opened file.

Parameters
[in]filehandleHandle to opened file
Returns
value GATE_RESULT_* code

◆ gate_file_get_attributes()

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.

Parameters
targetpathpath of file or directory to be accessed
attribspointer to variable that receives retrieved attribute flags
access_bitspointer to variable that receives retrieved access bits
Returns
value GATE_RESULT_* code

◆ gate_file_get_content()

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.

Parameters
[in]filepathFilesystem path of file to be read
[out]content_bufferOutput string initialized with the contents of the opened file
Returns
value GATE_RESULT_* code

◆ gate_file_get_content_buffer()

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.

Parameters
[in]filepathFilesystem path of file to be read
[out]content_bufferPointer to buffer to be filled with read bytes
[in,out]content_buffer_lenPointer to size of buffer, updated with finally read bytes
Returns
value GATE_RESULT_* code

◆ gate_file_get_content_lines()

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.

Parameters
[in]filepathFilesystem path of file to be read
[in]string_arrayAllocated arraylist (of type gate_string_t) to be filled with read lines
Returns
value GATE_RESULT_* code

◆ gate_file_get_owner()

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.

Parameters
[in]targetfilepath of file to be accessed
[out]owner_idoutput pointer to native owner-id
[out]owner_nameoutput pointer to string to be filled with name of owner account
Returns
value GATE_RESULT_* code

◆ gate_file_get_size()

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.

Parameters
targetfilepath of file to be accessed
filesizepointer to variable that receives the actual size
Returns
value GATE_RESULT_* code

◆ gate_file_get_times()

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.

Parameters
targetpathpath of file or directory to be accessed
modifiedoptional pointer to timestamp variable that receives the time of last modification
accessedoptional pointer to timestamp variable that receives the time of last access
createdoptional pointer to timestamp variable that receives the time of creation or update of the filesystem entry
Returns
value GATE_RESULT_* code

◆ gate_file_lock()

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.

Parameters
[in]filehandleHandle to opened file
[in]waitif "true" the function blocks until the lock can be applied, otherwise it returns an error if the file was already locked
Returns
value GATE_RESULT_* code

◆ gate_file_move()

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.

Parameters
srcfilepathpath of source file to be movied
dstfilepathpath of destination location where the file is moved
Returns
value GATE_RESULT_* code

◆ gate_file_open()

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.

Parameters
[in]filepathpath of file to be accessed
[in]flagsGATE_STREAM_OPEN_* indicating to access mode of the file
[out]filehandleoutput pointer to filehandle to be used in further calls
Returns
value GATE_RESULT_* code

◆ gate_file_openstream()

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.

Parameters
[in]filepathFilesystem path to file to be opened
[in]flagsGATE_STREAM_OPEN_* flags
[out]ptrtostreamptrPointer to store create file-stream object
Returns
GATE_RESULT_* result code

◆ gate_file_pos()

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.

Parameters
[in]filehandleHandle to opened file
[out]positionOutput variable that receives the absolute position in bytes
Returns
value GATE_RESULT_* code

◆ gate_file_read()

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.

Parameters
[in]filehandleHandle to opened file
[in]bufferBuffer to be filled with read bytes
[in]bufferlengthCapacity of buffer
[out]bufferusedOutput pointer receiving the amount of bytes from buffer that were filled
Returns
value GATE_RESULT_* code

◆ gate_file_read_link()

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.

Parameters
filepathpath of symbolic link file
realpathoutput string that is initialized with the real path
Returns
value GATE_RESULT_* code

◆ gate_file_seek()

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.

Parameters
[in]filehandleHandle to opened file
[in]positionPosition-update integer to be added file-pointer (based on origin)
[in]originGATE_FILE_SEEK_ORIGIN_* flag indicating where to seek operation should start
[out]newpositionOptional pointer that receives the final absolute position, that filepointer is pointing to
Returns
value GATE_RESULT_* code

◆ gate_file_set_attributes()

GATE_CORE_API gate_result_t gate_file_set_attributes ( gate_string_t const * targetpath,
gate_enumint_t attribs,
gate_enumint_t mask,
gate_enumint_t access_bits,
gate_enumint_t access_mask )

Changes attribute flags of a specific file or directory.

Parameters
targetpathpath of file or directory to be accessed
attribsnew attribute bits to be written to the targetpath
attribs_maskbitmask of attributes to written to the targetpath (attributes of non set bits preserve their current value)
access_bitsnew access bits values to be applied to targetpath
access_maskbitmask of access bits to be updated on targetpath
Returns
value GATE_RESULT_* code

◆ gate_file_set_content()

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.

Parameters
[in]filepathFilesystem path of file to be overwritten
[in]content_bufferString containing content to be written to file
Returns
value GATE_RESULT_* code

◆ gate_file_set_content_buffer()

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.

Parameters
[in]filepathFilesystem path of file to be overwritten
[in]content_bufferByte buffer containing data to be written to file
[in]content_buffer_lenLength of content_buffer in bytes
Returns
value GATE_RESULT_* code

◆ gate_file_set_content_lines()

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.

Parameters
[in]filepathFilesystem path of file to be overwritten
[in]string_arrayArray list of gate_string_t with lines to be written to file
Returns
value GATE_RESULT_* code

◆ gate_file_set_times()

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.

Parameters
targetpathpath of file or directory to be accessed
modifiedoptional pointer to modification timestamp that is written to the filesystem entry
accessedoptional pointer to access timestamp variable that is written to the filesystem entry
createdoptional pointer to entry-creation timestamp variable that is written to the filesystem entry
Returns
value GATE_RESULT_* code

◆ gate_file_size()

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.

Parameters
[in]filehandleHandle to opened file
[out]sizePointer that receives the current filesize in bytes
Returns
value GATE_RESULT_* code

◆ gate_file_split_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.

Parameters
[in]src_pathFilesystem path to be split
[out]parent_pathPointer to string to be initialized with partent directory path
[out]namePointer to string to be initialized with directory entry name
Returns
GATE_RESULT_* result code

◆ gate_file_split_path_components()

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.

Parameters
[in]src_pathFilesystem path to be split
[in]separator_charPath separator character
[out]out_arrayPointer to first item of string array to be initialized with path components
[in]out_array_capacityCount of items in out_array to be filled with path components
Returns
Amount if items in out_array that were initialized with path components

◆ gate_file_truncate()

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.

Parameters
[in]filehandleHandle to opened file
Returns
value GATE_RESULT_* code

◆ gate_file_unlock()

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()

Parameters
[in]filehandleHandle to opened file
Returns
value GATE_RESULT_* code

◆ gate_file_write()

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.

Parameters
[in]filehandleHandle to opened file
[in]bufferBuffer with bytes to be written to file
[in]bufferlengthLength of buffer in bytes
[out]writtenOutput pointer receiving the amount of bytes from buffer that were really written to file
Returns
value GATE_RESULT_* code