27 #ifndef LIBAUDCORE_VFS_H
28 #define LIBAUDCORE_VFS_H
35 #define VFS_IS_REGULAR (1 << 0)
36 #define VFS_IS_SYMLINK (1 << 1)
37 #define VFS_IS_DIR (1 << 2)
38 #define VFS_IS_EXECUTABLE (1 << 3)
39 #define VFS_EXISTS (1 << 4)
54 void * (* vfs_fopen_impl) (
const char *
filename,
const char * mode);
84 char * (* vfs_get_metadata_impl) (
VFSFile * file,
const char * field);
88 #define WARN_RETURN __attribute__ ((warn_unused_result))
102 int64_t
vfs_fwrite (
const void * ptr, int64_t size, int64_t nmemb,
VFSFile * file)
110 ((__format__ (__printf__, 2, 3)));
EXPORT int64_t vfs_fwrite(const void *ptr, int64_t size, int64_t nmemb, VFSFile *file)
Writes to a VFS stream.
bool_t vfs_fget_le64(uint64_t *value, VFSFile *stream) WARN_RETURN
Reads an unsigned 64-bit Little Endian value from the stream into native endian format.
bool_t vfs_fget_le32(uint32_t *value, VFSFile *stream) WARN_RETURN
Reads an unsigned 32-bit Little Endian value from the stream into native endian format.
bool_t vfs_fget_be32(uint32_t *value, VFSFile *stream) WARN_RETURN
Reads an unsigned 32-bit Big Endian value from the stream into native endian format.
EXPORT bool_t vfs_feof(VFSFile *file)
Returns whether or not the VFS stream has reached EOF.
bool_t vfs_fput_be32(uint32_t value, VFSFile *stream) WARN_RETURN
Writes an unsigned 32-bit native endian value into the stream as a Big Endian value.
int64_t(* vfs_ftell_impl)(VFSFile *file)
A function pointer which points to a ftell implementation.
bool_t vfs_fput_be16(uint16_t value, VFSFile *stream) WARN_RETURN
Writes an unsigned 16-bit native endian value into the stream as a Big Endian value.
EXPORT int64_t vfs_ftell(VFSFile *file)
Returns the current position in the VFS stream's buffer.
bool_t vfs_fget_le16(uint16_t *value, VFSFile *stream) WARN_RETURN
Reads an unsigned 16-bit Little Endian value from the stream into native endian format.
EXPORT int vfs_fclose(VFSFile *file)
Closes a VFS stream and destroys a VFSFile object.
EXPORT bool_t vfs_is_streaming(VFSFile *file)
Tests if a file is associated to streaming.
const char PluginHandle decoder const char PluginHandle decoder const char PluginHandle decoder void const PreferencesWidget int
EXPORT VFSFile * vfs_new(const char *path, VFSConstructor *vtable, void *handle)
bool_t vfs_fget_be16(uint16_t *value, VFSFile *stream) WARN_RETURN
Reads an unsigned 16-bit Big Endian value from the stream into native endian format.
int(* vfs_getc_impl)(VFSFile *stream)
A function pointer which points to a getc implementation.
bool_t vfs_fput_le16(uint16_t value, VFSFile *stream) WARN_RETURN
Writes an unsigned 16-bit native endian value into the stream as a Little Endian value.
int64_t(* vfs_fsize_impl)(VFSFile *file)
A function pointer which points to a fsize implementation.
EXPORT int vfs_ftruncate(VFSFile *file, int64_t length)
Truncates a VFS stream to a certain size.
int(* vfs_fseek_impl)(VFSFile *file, int64_t offset, int whence)
A function pointer which points to a fseek implementation.
EXPORT const char * vfs_get_filename(VFSFile *file)
int(* vfs_fclose_impl)(VFSFile *file)
A function pointer which points to a fclose implementation.
EXPORT int vfs_fseek(VFSFile *file, int64_t offset, int whence)
Performs a seek in given VFS stream.
int64_t(* vfs_fread_impl)(void *ptr, int64_t size, int64_t nmemb, VFSFile *file)
A function pointer which points to a fread implementation.
bool_t vfs_fput_le64(uint64_t value, VFSFile *stream) WARN_RETURN
Writes an unsigned 64-bit native endian value into the stream as a Big Endian value.
VFSConstructor objects contain the base vtables used for extrapolating a VFS stream.
EXPORT int64_t vfs_fread(void *ptr, int64_t size, int64_t nmemb, VFSFile *file)
Reads from a VFS stream.
EXPORT void vfs_set_lookup_func(VFSConstructor *(*func)(const char *scheme))
int64_t(* vfs_fwrite_impl)(const void *ptr, int64_t size, int64_t nmemb, VFSFile *file)
A function pointer which points to a fwrite implementation.
EXPORT void * vfs_get_handle(VFSFile *file)
int(* vfs_ungetc_impl)(int c, VFSFile *stream)
A function pointer which points to an ungetc implementation.
EXPORT int vfs_ungetc(int c, VFSFile *file)
Pushes a character back to the VFS stream.
bool_t vfs_fput_be64(uint64_t value, VFSFile *stream) WARN_RETURN
Writes an unsigned 64-bit native endian value into the stream as a Big Endian value.
EXPORT bool_t vfs_is_writeable(const char *path)
Tests if a file is writeable.
bool_t(* vfs_feof_impl)(VFSFile *file)
A function pointer which points to a feof implementation.
EXPORT VFSFile * vfs_fopen(const char *path, const char *mode)
Opens a stream from a VFS transport using one of the registered VFSConstructor handlers.
bool_t vfs_fput_le32(uint32_t value, VFSFile *stream) WARN_RETURN
Writes an unsigned 32-bit native endian value into the stream as a Big Endian value.
void vfs_file_get_contents(const char *filename, void **buf, int64_t *size)
Gets contents of the file into a buffer.
EXPORT char * vfs_get_metadata(VFSFile *file, const char *field)
Returns metadata about the stream.
int(* vfs_ftruncate_impl)(VFSFile *file, int64_t length)
A function pointer which points to a ftruncate implementation.
VFSFile objects describe an opened VFS stream, basically being similar in purpose as stdio FILE ...
EXPORT bool_t vfs_is_remote(const char *path)
Tests if a path is remote uri.
EXPORT void vfs_set_verbose(bool_t set)
EXPORT void vfs_rewind(VFSFile *file)
Rewinds a VFS stream.
EXPORT int vfs_getc(VFSFile *file)
Reads a character from a VFS stream.
char * vfs_fgets(char *s, int n, VFSFile *stream) WARN_RETURN
Reads a string of characters from a stream, ending in newline or EOF.
void(* vfs_rewind_impl)(VFSFile *file)
function pointer which points to a rewind implementation.
EXPORT int64_t vfs_fsize(VFSFile *file)
Returns size of the file.
bool_t vfs_fget_be64(uint64_t *value, VFSFile *stream) WARN_RETURN
Reads an unsigned 64-bit Big Endian value from the stream into native endian format.
EXPORT bool_t vfs_file_test(const char *path, int test)
Wrapper for g_file_test().
int vfs_fprintf(VFSFile *stream, char const *format,...) __attribute__((__format__(__printf__