mirror of
https://git.disroot.org/80486DX2-66/polonium.git
synced 2024-12-26 23:20:22 +05:30
always use name file
instead of f
This commit is contained in:
parent
0833f7a4d2
commit
6d0e05de44
@ -23,7 +23,7 @@ enum file_types {
|
|||||||
typedef enum file_types file_type_t;
|
typedef enum file_types file_type_t;
|
||||||
|
|
||||||
/* function definitions */
|
/* function definitions */
|
||||||
file_type_t determine_file_type(FILE* f, const char* file_name);
|
file_type_t determine_file_type(FILE* file, const char* file_name);
|
||||||
const char* file_type_to_string(file_type_t type);
|
const char* file_type_to_string(file_type_t type);
|
||||||
|
|
||||||
#endif /* _FILE_TYPE_H */
|
#endif /* _FILE_TYPE_H */
|
||||||
|
@ -5,23 +5,23 @@
|
|||||||
if (ends_with_casefold(file_name, ext) && is_valid_file(file, type)) \
|
if (ends_with_casefold(file_name, ext) && is_valid_file(file, type)) \
|
||||||
return true
|
return true
|
||||||
#define FILE_TYPE_FREAD_ERROR_HANDLING \
|
#define FILE_TYPE_FREAD_ERROR_HANDLING \
|
||||||
if (feof(f)) \
|
if (feof(file)) \
|
||||||
return false; \
|
return false; \
|
||||||
\
|
\
|
||||||
PERROR_MACRO("fread"); \
|
PERROR_MACRO("fread"); \
|
||||||
exit(EXIT_FAILURE)
|
exit(EXIT_FAILURE)
|
||||||
|
|
||||||
/* function definitions */
|
/* function definitions */
|
||||||
static bool header_check(FILE* f, const char* id, size_t length);
|
static bool header_check(FILE* file, const char* id, size_t length);
|
||||||
static bool is_valid_file(FILE* f, file_type_t type);
|
static bool is_valid_file(FILE* file, file_type_t type);
|
||||||
|
|
||||||
/* function implementations */
|
/* function implementations */
|
||||||
static bool header_check(FILE* f, const char* id, size_t length) {
|
static bool header_check(FILE* file, const char* id, size_t length) {
|
||||||
rewind(f);
|
rewind(file);
|
||||||
|
|
||||||
for (size_t i = 0; i < length; i++) {
|
for (size_t i = 0; i < length; i++) {
|
||||||
char c;
|
char c;
|
||||||
if (fread(&c, sizeof(char), 1, f) != 1) {
|
if (fread(&c, sizeof(char), 1, file) != 1) {
|
||||||
FILE_TYPE_FREAD_ERROR_HANDLING;
|
FILE_TYPE_FREAD_ERROR_HANDLING;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,10 +32,10 @@ static bool header_check(FILE* f, const char* id, size_t length) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool is_valid_file(FILE* f, file_type_t type) {
|
static bool is_valid_file(FILE* file, file_type_t type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case FILE_TYPE_BMP: return header_check(f, "BM", 2);
|
case FILE_TYPE_BMP: return header_check(file, "BM", 2);
|
||||||
case FILE_TYPE_WAV: return header_check(f, "RIFF", 4);
|
case FILE_TYPE_WAV: return header_check(file, "RIFF", 4);
|
||||||
default:
|
default:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user