mirror of
https://github.com/jtheoof/swappy.git
synced 2024-08-17 02:30:47 +03:00
refactor(file): use glib helpers for file checking
This commit is contained in:
parent
aed2bfe294
commit
319a6107f5
@ -18,7 +18,7 @@ bool config_get_storage_path(struct swappy_state *state) {
|
||||
if (wordexp(storage_paths[i], &p, 0) == 0) {
|
||||
char *path = g_strdup(p.we_wordv[0]);
|
||||
wordfree(&p);
|
||||
if (folder_exists(path)) {
|
||||
if (path && folder_exists(path)) {
|
||||
g_info("storage path is: %s", path);
|
||||
state->storage_path = path;
|
||||
return true;
|
||||
|
12
src/file.c
12
src/file.c
@ -12,19 +12,11 @@
|
||||
#define BLOCK_SIZE 1024
|
||||
|
||||
bool folder_exists(const char *path) {
|
||||
struct stat sb;
|
||||
|
||||
stat(path, &sb);
|
||||
|
||||
return (stat(path, &sb) == 0 && S_ISDIR(sb.st_mode));
|
||||
return g_file_test(path, G_FILE_TEST_IS_DIR);
|
||||
}
|
||||
|
||||
bool file_exists(const char *path) {
|
||||
struct stat sb;
|
||||
|
||||
stat(path, &sb);
|
||||
|
||||
return (stat(path, &sb) == 0 && S_ISREG(sb.st_mode));
|
||||
return g_file_test(path, G_FILE_TEST_EXISTS);
|
||||
}
|
||||
|
||||
char *file_dump_stdin_into_a_temp_file() {
|
||||
|
Loading…
Reference in New Issue
Block a user