fs

Synopsis

File system API much like Node's fs module

Version
0.1.0
Source
jwerle/fs.c
License
MIT

API

Details

fs_chown ()
int
fs_chown            (const char * path, int uid, int gid);

Changes ownership of a given file path to a given owner and group


fs_close ()
int
fs_close            (FILE * file);

Closes a given file descriptor


fs_error ()
void
fs_error            (const char * prefix);

Prints the last error to stderr


fs_exists ()
int
fs_exists           (const char * path);

Check if the given `path` exists


fs_fchown ()
int
fs_fchown           (FILE * file, int uid, int gid);

Change ownership of a given file descriptor to a given owner and group


fs_fnread ()
char *
fs_fnread           (FILE * file, int len);

Reads a file by a given file descriptor by a given `n` number of bytes


fs_fnwrite ()
int
fs_fnwrite          (FILE * file, const char * buffer, int len);

Writes `n` bytes of a buffer to a given file stream


fs_fread ()
char *
fs_fread            (FILE * file);

Reads a file by a given file descriptor


fs_fsize ()
size_t
fs_fsize            (FILE * file);

Returns the size of a file from a given file descriptor


fs_fstat ()
fs_stats *
fs_fstat            (FILE * file);

Stats a given file descriptor


fs_ftruncate ()
int
fs_ftruncate        (FILE * file, int len);

Truncates a file to a specified length from a given file descriptor


fs_fwrite ()
int
fs_fwrite           (FILE * file, const char * buffer);

Writes a buffer to a given file stream


fs_lchown ()
int
fs_lchown           (const char * path, int uid, int gid);

Change ownership of a given link path to a given owner and group


fs_lstat ()
fs_stats *
fs_lstat            (const char * path);

Stats a given link path


fs_mkdir ()
int
fs_mkdir            (const char * path, int mode);

Makes a directory and returns 0 on success or -1 on failure


fs_nread ()
char *
fs_nread            (const char * path, int len);

Reads a file by a given file path by a given `n` number of bytes


fs_nwrite ()
int
fs_nwrite           (const char * path, const char * buffer, int len);

Writes `n` bytes of a buffer to a given file path


fs_open ()
FILE *
fs_open             (const char * path, const char * flags);

Opens a file with given flags and returns a file descriptor


fs_read ()
char *
fs_read             (const char * path);

Reads a file by a given file path


fs_rename ()
int
fs_rename           (const char * from, const char * to);

Moves a path to a new destination


fs_rmdir ()
int
fs_rmdir            (const char * path);

Removes a directory and returns 0 on success and -1 on failure


fs_size ()
size_t
fs_size             (const char * path);

Returns the size of a file from a given file path


fs_stat ()
fs_stats *
fs_stat             (const char * path);

Stats a given path and returns a `struct stat`


fs_truncate ()
int
fs_truncate         (const char * path, int len);

Truncates a file to a specified len from a given file path


fs_write ()
int
fs_write            (const char * path, const char * buffer);

Writes a buffer to a given file path