Claude Chappe' Curse - A C Game
Logo Institut d'Informatique Claude Chappe Logo Université de Le Mans Logo Raeptor Production
 
Loading...
Searching...
No Matches
OSIO File Operations

Functions for file operations and error handling. More...

Functions

int osio_save_file (char *path, char *relativePath, char *filter)
 Saves a file to the specified path with a given filter.
 
int osio_open_file (char *path, char *relativePath, char *filter)
 Opens a file from the specified path with a given filter.
 
int osio_print_error (char *msg)
 Prints an error message to the standard error output.
 
int update_cwd ()
 Updates the current working directory.
 
int absolute_path_to_relative (char *path)
 Converts an absolute file path to a relative path.
 
int osio_find (dirent_t ***namelist, const char *path, int(*filter)(const dirent_t *entry))
 Finds files in a directory that match a given filter.
 

Detailed Description

Functions for file operations and error handling.

Function Documentation

◆ osio_save_file()

int osio_save_file ( char *  path,
char *  relativePath,
char *  filter 
)

Saves a file to the specified path with a given filter.

This function attempts to save a file to the location specified by the path parameter, applying the filter specified by the filter parameter. The filter can be used to specify file types or other criteria.

Parameters
pathThe path where the file should be saved.
filterThe filter to apply when saving the file.
Returns
int Returns 0 on success, or a non-zero error code on failure.

◆ osio_open_file()

int osio_open_file ( char *  path,
char *  relativePath,
char *  filter 
)

Opens a file from the specified path with a given filter.

This function attempts to open a file from the location specified by the path parameter, applying the filter specified by the filter parameter. The filter can be used to specify file types or other criteria.

Parameters
pathThe path from where the file should be opened.
relativePathThe relative path to the file.
filterThe filter to apply when opening the file.
Returns
int Returns 0 on success, or a non-zero error code on failure.

◆ osio_print_error()

int osio_print_error ( char *  msg)

Prints an error message to the standard error output.

This function prints the error message specified by the msg parameter to the standard error output (stderr). It can be used for logging errors or debugging purposes.

Parameters
msgThe error message to be printed.
Returns
int Returns 0 on success, or a non-zero error code on failure.

◆ update_cwd()

int update_cwd ( )

Updates the current working directory.

This function updates the current working directory to the latest state. It can be used to ensure that the program is operating in the correct directory context.

Returns
int Returns 0 on success, or a non-zero error code on failure.

◆ absolute_path_to_relative()

int absolute_path_to_relative ( char *  path)

Converts an absolute file path to a relative path.

This function converts the absolute file path specified by the path parameter to a relative path. It can be useful for creating paths that are relative to the current working directory or another base directory.

Parameters
pathThe absolute path to be converted to a relative path.
Returns
int Returns 0 on success, or a non-zero error code on failure.

◆ osio_find()

int osio_find ( dirent_t ***  namelist,
const char *  path,
int(*)(const dirent_t *entry)  filter 
)

Finds files in a directory that match a given filter.

This function searches for files in the directory specified by the path parameter that match the filter function provided by the filter parameter. The filter function should return 1 for files that match the criteria, and 0 for files that do not.

Parameters
namelistA pointer to the list of directory entries.
pathThe path to the directory where files should be searched.
filterThe filter function to apply to the directory entries.
Returns
int Returns the number of files found, or a non-zero error code on failure.