Bare API
frogfs/frogfs.h
Defines
-
FROGFS_MAGIC
Magic number used in the frogfs file header.
-
FROGFS_VER_MAJOR
Major version this source distribution supports.
-
FROGFS_VER_MINOR
Minor version this source distribution supports.
-
FROGFS_OPEN_RAW
Flag for frogfs_open to open any file as raw. Useful to pass compressed data over a transport such as HTTP.
Functions
-
frogfs_fs_t *frogfs_init(const frogfs_config_t *conf)
Initialize and return a frogfs_fs_t instance.
- Parameters:
config – [in] frogfs configuration
- Returns:
frogfs_fs_t pointer or NULL on error
-
void frogfs_deinit(frogfs_fs_t *fs)
Tear down a frogfs_fs_t instance.
- Parameters:
fs – [in] frogfs_fs_t pointer
-
const frogfs_entry_t *frogfs_get_entry(const frogfs_fs_t *fs, const char *path)
Get frogfs entry for path.
- Parameters:
fs – [in] frogfs_fs_t pointer
path – [in] path string
- Returns:
frogfs_entry_t pointer or NULL if path was not found
-
const char *frogfs_get_name(const frogfs_entry_t *entry)
Get name for frogfs entry.
- Parameters:
entry – [in] frogfs_entry_t pointer
- Returns:
name string
-
char *frogfs_get_path(const frogfs_fs_t *fs, const frogfs_entry_t *entry)
Get full path for frogfs entry.
- Parameters:
fs – [in] frogfs_fs_t pointer
entry – [in] frogfs_entry_t pointer
- Returns:
full path string or NULL if entry is NULL
-
int frogfs_is_dir(const frogfs_entry_t *entry)
Return if entry is a directory.
- Parameters:
entry – [in] frogfs_entry_t pointer
- Returns:
1 if directory, 0 otherwise
-
int frogfs_is_file(const frogfs_entry_t *entry)
Return if entry is a file.
- Parameters:
entry – [in] frogfs_entry_t pointer
- Returns:
1 if file, 0 otherwise
-
void frogfs_stat(const frogfs_fs_t *fs, const frogfs_entry_t *entry, frogfs_stat_t *st)
Get information about a frogfs entry.
- Parameters:
fs – [in] frogfs_fs_t pointer
entry – [in] frogfs_entry_t pointer
st – [out] frogfs_stat_t structure
-
frogfs_fh_t *frogfs_open(const frogfs_fs_t *fs, const frogfs_entry_t *entry, unsigned int flags)
Open a frogfs entry as a file from a frogfs_fs_t instance.
- Parameters:
fs – [in] frogfs_fs_t poitner
entry – [in] frogfs_entry_t pointer
flags – [in] open flags
- Returns:
frogfs_fh_t or NULL if not found
-
void frogfs_close(frogfs_fh_t *fh)
Close an open file entry.
- Parameters:
f – [in] frogfs_fh_t pointer
-
int frogfs_is_raw(frogfs_fh_t *fh)
Determine if file handle is opened raw.
- Parameters:
f – [in] frogfs_fh_t pointer
- Returns:
1 if file is open raw, 0 otherwise
-
ssize_t frogfs_read(frogfs_fh_t *fh, void *buf, size_t len)
Read data from an open file entry.
- Parameters:
f – [in] frogfs_fh_t pointer
buf – [out] buffer to read into
len – [in] maximum number of bytes to read
- Returns:
actual number of bytes read, zero if end of file reached
-
ssize_t frogfs_seek(frogfs_fh_t *fh, long offset, int mode)
Seek to a position within an open file entry.
- Parameters:
f – [in] frogfs_fh_t pointer
offset – [in] file position (relative or absolute)
mode – [in] SEEK_SET, SEEK_CUR, or SEEK_END
- Returns:
current position in file or < 0 upon error
-
size_t frogfs_tell(frogfs_fh_t *fh)
Get the current position in an open file entry.
- Parameters:
f – [in] frogfs_fh_t pointer
- Returns:
current position in file or < 0 upon error
-
size_t frogfs_access(frogfs_fh_t *fh, const void **buf)
Get raw memory for raw file entry.
- Parameters:
f – [in] frogfs_fh_t pointer
buf – [out] pointer pointer to buf
- Returns:
length of raw data
-
frogfs_dh_t *frogfs_opendir(frogfs_fs_t *fs, const frogfs_entry_t *entry)
Open a directory for reading child entrys.
- Parameters:
fs – [in] frogfs_fs_t pointer
entry – [in] frogfs_entry_t pointer to root director
- Returns:
frogfs_dh_t pointer or NULL if invalid
-
void frogfs_closedir(frogfs_dh_t *dh)
Close a directory.
- Parameters:
d – [in] frogfs_dh_t pointer
-
const frogfs_entry_t *frogfs_readdir(frogfs_dh_t *dh)
Get the next child entry in directory.
- Parameters:
d – [in] frogfs_dh_t pointer
- Returns:
frogfs_entry_t pointer or NULL if end has been reached
-
void frogfs_seekdir(frogfs_dh_t *dh, uint16_t loc)
Set dir entry index to a value returned by frogfs_telldir for the current frogfs_dh_t pointer; any other values are undefined.
- Parameters:
d – [in] frogfs_dh_t pointer
loc – [in] entry index
-
uint16_t frogfs_telldir(frogfs_dh_t *dh)
Return the current entry index for a directory.
- Parameters:
d – [in] frogfs_dh_t pointer
- Returns:
entry index
Enums
Typedefs
-
typedef struct frogfs_fs_t frogfs_fs_t
A frogfs filesystem handle.
-
typedef struct frogfs_entry_t frogfs_entry_t
Fiilesystem entry pointer.
Structs
-
struct frogfs_config_t
Configuration for the frogfs_init function.
-
struct frogfs_stat_t
Structure filled by the frogfs_stat function.
Public Members
-
frogfs_entry_type_t type
entry type
-
size_t size
uncompressed file size
-
frogfs_comp_algo_t compression
compression type
-
size_t compressed_sz
compressed file size
-
frogfs_entry_type_t type
-
struct frogfs_fh_t
A frogfs file handle.
-
struct frogfs_dh_t
A frogfs directory handle.