Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenlib/intern/storage.c
| Show First 20 Lines • Show All 442 Lines • ▼ Show 20 Lines | |||||
| */ | */ | ||||
| bool BLI_is_file(const char *path) | bool BLI_is_file(const char *path) | ||||
| { | { | ||||
| const int mode = BLI_exists(path); | const int mode = BLI_exists(path); | ||||
| return (mode && !S_ISDIR(mode)); | return (mode && !S_ISDIR(mode)); | ||||
| } | } | ||||
| /** | /** | ||||
| * Check if specified directory contains any files or subdirectories. | |||||
| */ | |||||
| bool BLI_dir_is_empty(const char *path) | |||||
| { | |||||
| if (!BLI_is_dir(path)) { | |||||
| return false; | |||||
| } | |||||
| DIR *dir; | |||||
| if ((dir = opendir(path)) != NULL) { | |||||
| const struct dirent *fname; | |||||
| while ((fname = readdir(dir)) != NULL) { | |||||
| if (!FILENAME_IS_PARENT(fname->d_name) && !FILENAME_IS_CURRENT(fname->d_name)) { | |||||
| return false; | |||||
| } | |||||
| } | |||||
| } | |||||
| return true; | |||||
| } | |||||
| /** | |||||
| * Use for both text and binary file reading. | * Use for both text and binary file reading. | ||||
| */ | */ | ||||
| static void *file_read_data_as_mem_impl(FILE *fp, | static void *file_read_data_as_mem_impl(FILE *fp, | ||||
| bool read_size_exact, | bool read_size_exact, | ||||
| size_t pad_bytes, | size_t pad_bytes, | ||||
| size_t *r_size) | size_t *r_size) | ||||
| { | { | ||||
| BLI_stat_t st; | BLI_stat_t st; | ||||
| ▲ Show 20 Lines • Show All 215 Lines • Show Last 20 Lines | |||||