libcproject
C static library easier to use than libc (C standard library).
filesystem.h File Reference
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <pwd.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "string.h"
#include "types.h"
Include dependency graph for filesystem.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int filesystem_read (string_t path, byte_t **file_content, size_t *file_size)
 Read the content of a file. More...
 
int filesystem_write (string_t path, byte_t *file_content, size_t file_size)
 Write the content to a file. More...
 
bool filesystem_exists (string_t path)
 Check if a path exists. More...
 
int filesystem_remove (string_t path)
 Removes a path. More...
 
string_t filesystem_get_mimetype (string_t path)
 Get the mimetype of a file based on its extension. More...
 

Function Documentation

◆ filesystem_read()

int filesystem_read ( string_t  path,
byte_t **  file_content,
size_t *  file_size 
)

Read the content of a file.

Parameters
path
file_content
file_sizeThe size of the file that was read (mutated by the function).
Return values
-1if the file does not exist or if there is an error.
0for success.
Returns
int
Since
v1.0.0

◆ filesystem_write()

int filesystem_write ( string_t  path,
byte_t file_content,
size_t  file_size 
)

Write the content to a file.

Parameters
path
file_content
file_size
Return values
-1if there is an error.
0for success.
Returns
int
Since
v1.0.0

◆ filesystem_exists()

bool filesystem_exists ( string_t  path)

Check if a path exists.

Parameters
path
Returns
bool
Since
v3.1.0

◆ filesystem_remove()

int filesystem_remove ( string_t  path)

Removes a path.

Parameters
path
Returns
int
Return values
-1if there is an error.
0for success.
Returns
int
Since
v3.1.0

◆ filesystem_get_mimetype()

string_t filesystem_get_mimetype ( string_t  path)

Get the mimetype of a file based on its extension.

Parameters
path
See also
https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
https://www.iana.org/assignments/media-types/media-types.xhtml
Returns
string_t
Since
v1.0.0