18 #if !defined(S_ISREG) && defined(S_IFMT) && defined(S_IFREG) 19 #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) 24 DEBUG_ENTRY(
"const char *file_name = <%s>, const char *mode = <%s>, void **file_descriptor = <%p>", file_name, mode, file_descriptor)
38 #if defined(WIN32) || defined(WIN64) 39 fopen_s(&file, file_name, mode);
41 file = fopen(file_name, mode);
43 *file_descriptor = file;
54 DEBUG_ENTRY(
"void *file_descriptor = <%p>", file_descriptor)
68 mcl_int32_t result = fclose((FILE *)file_descriptor);
80 DEBUG_ENTRY(
"const void *data = <%p>, mcl_size_t size = <%u>, mcl_size_t count = <%u>, void *file_descriptor = <%p>", data, size, count, file_descriptor)
92 mcl_size_t actual_count = fwrite(data, size, count, (FILE *)file_descriptor);
93 if (count == actual_count)
99 MCL_ERROR(
"Data can not be written to file.");
107 DEBUG_ENTRY(
"void *data = <%p>, mcl_size_t size = <%u>, mcl_size_t count = <%u>, void *file_descriptor = <%p>, mcl_size_t *actual_count = <%p>", data, size, count,
108 file_descriptor, actual_count)
110 *actual_count = fread(data, size, count, (FILE *)file_descriptor);
117 DEBUG_ENTRY(
"const char *data = <%s>, void *file_descriptor = <%p>", data, file_descriptor)
121 mcl_int32_t result = fputs(data, (FILE *)file_descriptor);
128 MCL_ERROR(
"Data can not be written to file.");
137 DEBUG_ENTRY(
"char *data = <%p>, mcl_size_t data_size = <%u>, void *file_descriptor = <%p>", data, data_size, file_descriptor)
141 char *output = fgets(data, (
int)data_size, (FILE *)file_descriptor);
157 DEBUG_ENTRY(
"void *file_descriptor = <%p>, struct stat *file_attributes = <%p>", file_descriptor, file_attributes)
163 #if defined(WIN32) || defined(WIN64) 164 result = fstat(_fileno((FILE *)file_descriptor), file_attributes);
166 result = fstat(fileno((FILE *)file_descriptor), file_attributes);
175 MCL_ERROR(
"Error in retrieving file attributes.");
184 DEBUG_ENTRY(
"void *file_descriptor = <%p>", file_descriptor)
198 #if defined(WIN32) || defined(WIN64) 199 result = fflush((FILE *)file_descriptor);
201 result = fflush((FILE *)file_descriptor);
218 DEBUG_ENTRY(
"const mcl_stat_t *file_attributes = <%p>", file_attributes)
222 is_regular_file = S_ISREG(file_attributes->st_mode);
226 return is_regular_file;
E_MCL_ERROR_CODE file_util_fflush_without_log(void *file_descriptor)
E_MCL_ERROR_CODE file_util_fwrite(const void *data, mcl_size_t size, mcl_size_t count, void *file_descriptor)
E_MCL_ERROR_CODE file_util_fflush(void *file_descriptor)
E_MCL_ERROR_CODE file_util_fgets(char *data, mcl_size_t data_size, void *file_descriptor)
E_MCL_ERROR_CODE file_util_fopen_without_log(const char *file_name, const char *mode, void **file_descriptor)
#define MCL_FALSE
MCL bool type.
E_MCL_ERROR_CODE file_util_fputs(const char *data, void *file_descriptor)
Log utility module header file.
E_MCL_ERROR_CODE
MCL Error code definitions. Every function returning an error code uses this enum values...
E_MCL_ERROR_CODE file_util_fopen(const char *file_name, const char *mode, void **file_descriptor)
E_MCL_ERROR_CODE file_util_fwrite_without_log(const void *data, mcl_size_t size, mcl_size_t count, void *file_descriptor)
Definitions module header file.
File utility module header file.
void file_util_fread(void *data, mcl_size_t size, mcl_size_t count, void *file_descriptor, mcl_size_t *actual_count)
E_MCL_ERROR_CODE file_util_fclose(void *file_descriptor)
E_MCL_ERROR_CODE file_util_fstat(void *file_descriptor, struct stat *file_attributes)
mcl_bool_t file_util_check_if_regular_file(const mcl_stat_t *file_attributes)
E_MCL_ERROR_CODE file_util_fclose_without_log(void *file_descriptor)