File utility module implementation file. More...
Go to the source code of this file.
Functions | |
mcl_error_t | mcl_file_util_fopen (const char *file_name, const char *mode, void **file_descriptor) |
mcl_error_t | mcl_file_util_fopen_without_log (const char *file_name, const char *mode, void **file_descriptor) |
mcl_error_t | mcl_file_util_fclose (void *file_descriptor) |
mcl_error_t | mcl_file_util_fclose_without_log (void *file_descriptor) |
mcl_error_t | mcl_file_util_fwrite (const void *data, mcl_size_t size, mcl_size_t count, void *file_descriptor) |
mcl_error_t | mcl_file_util_fwrite_without_log (const void *data, mcl_size_t size, mcl_size_t count, void *file_descriptor) |
void | mcl_file_util_fread (void *data, mcl_size_t size, mcl_size_t count, void *file_descriptor, mcl_size_t *actual_count) |
mcl_error_t | mcl_file_util_fputs (const char *data, void *file_descriptor) |
mcl_error_t | mcl_file_util_fgets (char *data, mcl_size_t data_size, void *file_descriptor) |
mcl_error_t | mcl_file_util_fflush (void *file_descriptor) |
mcl_error_t | mcl_file_util_fflush_without_log (void *file_descriptor) |
void | mcl_file_util_rewind (void *file_descriptor) |
mcl_bool_t | mcl_file_util_check_if_regular_file (void *file_descriptor) |
mcl_size_t | mcl_file_util_get_file_size (void *file_descriptor) |
mcl_time_t | mcl_file_util_get_time_of_last_status_change (void *file_descriptor) |
Variables | |
static const char | mcl_no_file_system_message [] = "MCL file utility cannot be used." |
File utility module implementation file.
Definition in file file_util.c.
mcl_bool_t mcl_file_util_check_if_regular_file | ( | void * | file_descriptor | ) |
This function is used to check if file is a regular file.
[in] | file_descriptor | File descriptor obtained by opening the file. |
Definition at line 265 of file file_util.c.
References MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_ERROR_STRING, MCL_FALSE, mcl_no_file_system_message, and MCL_OK.
mcl_error_t mcl_file_util_fclose | ( | void * | file_descriptor | ) |
This function is used to close the file opened beforehand.
[in] | file_descriptor | File descriptor of the file to close. |
Definition at line 66 of file file_util.c.
References MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_ERROR_STRING, MCL_FAIL, mcl_file_util_fclose_without_log(), and mcl_no_file_system_message.
mcl_error_t mcl_file_util_fclose_without_log | ( | void * | file_descriptor | ) |
This function is used to close the file opened beforehand. It has the same functionality as mcl_file_util_fclose except that it does not log any debug messages.
[in] | file_descriptor | File descriptor of the file to close. |
Definition at line 83 of file file_util.c.
References MCL_FAIL, MCL_NULL, and MCL_OK.
Referenced by mcl_file_util_fclose().
mcl_error_t mcl_file_util_fflush | ( | void * | file_descriptor | ) |
This function flushes pending content to file_descriptor
.
[in] | file_descriptor | File descriptor obtained by opening the file. |
Definition at line 208 of file file_util.c.
References MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_ERROR_STRING, MCL_FAIL, mcl_file_util_fflush_without_log(), and mcl_no_file_system_message.
mcl_error_t mcl_file_util_fflush_without_log | ( | void * | file_descriptor | ) |
This function flushes pending content to file_descriptor
. It has the same functionality as mcl_file_util_fflush except that it does not log any debug messages.
[in] | file_descriptor | File descriptor obtained by opening the file. |
Definition at line 225 of file file_util.c.
References MCL_ERROR, MCL_ERROR_STRING, MCL_FAIL, mcl_no_file_system_message, and MCL_OK.
Referenced by mcl_file_util_fflush().
mcl_error_t mcl_file_util_fgets | ( | char * | data, |
mcl_size_t | data_size, | ||
void * | file_descriptor | ||
) |
This function is used to read a string from a file. A maximum of data_size
- 1 characters are read from the file and a terminating null character is immediately added after the last character of data
. No additional characters are read after the new line character of after end of file.
[out] | data | Pointer to the string to read from file. |
[in] | data_size | Maximum number of characters to read from file including the null terminator. |
[in] | file_descriptor | File descriptor of the file to read from. |
Definition at line 182 of file file_util.c.
References MCL_DEBUG, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_ERROR_STRING, MCL_FAIL, mcl_no_file_system_message, MCL_NULL, and MCL_OK.
mcl_error_t mcl_file_util_fopen | ( | const char * | file_name, |
const char * | mode, | ||
void ** | file_descriptor | ||
) |
This function is used to open a file.
[in] | file_name | File name to open. |
[in] | mode | Mode of the file to open. Please refer to the modes of fopen() function in ANSI standard. |
[out] | file_descriptor | File descriptor for the file opened. This descriptor is used to process the file. |
Definition at line 26 of file file_util.c.
References MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_ERROR_STRING, MCL_FAIL, mcl_file_util_fopen_without_log(), and mcl_no_file_system_message.
mcl_error_t mcl_file_util_fopen_without_log | ( | const char * | file_name, |
const char * | mode, | ||
void ** | file_descriptor | ||
) |
This function is used to open a file. It has the same functionality as mcl_file_util_fopen except that it does not log any debug messages.
[in] | file_name | File name to open. |
[in] | mode | Mode of the file to open. Please refer to the modes of fopen() function in ANSI standard. |
[out] | file_descriptor | File descriptor for the file opened. This descriptor is used to process the file. |
Definition at line 43 of file file_util.c.
References MCL_FAIL, MCL_NULL, and MCL_OK.
Referenced by mcl_file_util_fopen().
mcl_error_t mcl_file_util_fputs | ( | const char * | data, |
void * | file_descriptor | ||
) |
This function is used to write a string to a file. The terminating null character is not written.
[in] | data | Pointer to the string to write to file. |
[in] | file_descriptor | File descriptor of the file to write to. |
Definition at line 156 of file file_util.c.
References MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_ERROR, MCL_ERROR_STRING, MCL_FAIL, mcl_no_file_system_message, and MCL_OK.
void mcl_file_util_fread | ( | void * | data, |
mcl_size_t | size, | ||
mcl_size_t | count, | ||
void * | file_descriptor, | ||
mcl_size_t * | actual_count | ||
) |
This function is used to read data from a file into memory.
[in] | data | Pointer to the memory (size x count bytes allocated a priori) to store the data from the file. |
[in] | size | Size of each element requested. |
[in] | count | Number of elements requested. |
[in] | file_descriptor | File descriptor of the file to read from. |
[out] | actual_count | Number of elements actually read from file. |
Definition at line 142 of file file_util.c.
References MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_ERROR_STRING, and mcl_no_file_system_message.
mcl_error_t mcl_file_util_fwrite | ( | const void * | data, |
mcl_size_t | size, | ||
mcl_size_t | count, | ||
void * | file_descriptor | ||
) |
This function is used to write data in memory to a file.
[in] | data | Pointer to the data to write to file. |
[in] | size | Size of each element in data . |
[in] | count | Number of elements in data . |
[in] | file_descriptor | File descriptor of the file to write to. |
Definition at line 103 of file file_util.c.
References MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_ERROR_STRING, MCL_FAIL, mcl_file_util_fwrite_without_log(), and mcl_no_file_system_message.
mcl_error_t mcl_file_util_fwrite_without_log | ( | const void * | data, |
mcl_size_t | size, | ||
mcl_size_t | count, | ||
void * | file_descriptor | ||
) |
This function is used to write data in memory to a file. It has the same functionality as mcl_file_util_fwrite except that it does not log any debug messages.
[in] | data | Pointer to the data to write to file. |
[in] | size | Size of each element in data . |
[in] | count | Number of elements in data . |
[in] | file_descriptor | File descriptor of the file to write to. |
Definition at line 121 of file file_util.c.
References MCL_ERROR, MCL_FAIL, and MCL_OK.
Referenced by mcl_file_util_fwrite().
mcl_size_t mcl_file_util_get_file_size | ( | void * | file_descriptor | ) |
This function is used to get size of file.
[in] | file_descriptor | File descriptor obtained by opening the file. |
Definition at line 288 of file file_util.c.
References MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_ERROR_STRING, mcl_no_file_system_message, and MCL_OK.
mcl_time_t mcl_file_util_get_time_of_last_status_change | ( | void * | file_descriptor | ) |
This function is used to get time of last status change of the file.
[in] | file_descriptor | File descriptor obtained by opening the file. |
Definition at line 309 of file file_util.c.
References MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_ERROR, MCL_ERROR_STRING, MCL_FAIL, mcl_no_file_system_message, and MCL_OK.
void mcl_file_util_rewind | ( | void * | file_descriptor | ) |
This function is used to set position of stream to the beginning.
[in] | file_descriptor | Descriptor of the file. |
Definition at line 249 of file file_util.c.
References MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_ERROR_STRING, mcl_no_file_system_message, and MCL_NULL.
|
static |
Definition at line 19 of file file_util.c.
Referenced by mcl_file_util_check_if_regular_file(), mcl_file_util_fclose(), mcl_file_util_fflush(), mcl_file_util_fflush_without_log(), mcl_file_util_fgets(), mcl_file_util_fopen(), mcl_file_util_fputs(), mcl_file_util_fread(), mcl_file_util_fwrite(), mcl_file_util_get_file_size(), mcl_file_util_get_time_of_last_status_change(), and mcl_file_util_rewind().