summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRay Strode <rstrode@redhat.com>2007-05-23 15:32:06 -0400
committerRay Strode <rstrode@redhat.com>2007-05-23 15:32:06 -0400
commit178fd654ab7e31cef4dd7d72bed5f6dba12f46f8 (patch)
tree58a14cbeca7052f518c485ec7fa10902b5525757 /src
parent23aad9450761ff34aff7b5ddda2f98987cd3bdbb (diff)
add new functions that check if a file or dir exists
Diffstat (limited to 'src')
-rw-r--r--src/ply-utils.c22
-rw-r--r--src/ply-utils.h3
2 files changed, 25 insertions, 0 deletions
diff --git a/src/ply-utils.c b/src/ply-utils.c
index 5b531b7..a3f29a0 100644
--- a/src/ply-utils.c
+++ b/src/ply-utils.c
@@ -349,4 +349,26 @@ ply_restore_errno (void)
errno = errno_stack[errno_stack_position];
}
+bool
+ply_directory_exists (const char *dir)
+{
+ struct stat file_info;
+
+ if (stat (dir, &file_info) < 0)
+ return false;
+
+ return S_ISDIR (file_info.st_mode);
+}
+
+bool
+ply_file_exists (const char *file)
+{
+ struct stat file_info;
+
+ if (stat (file, &file_info) < 0)
+ return false;
+
+ return S_ISREG (file_info.st_mode);
+}
+
/* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
diff --git a/src/ply-utils.h b/src/ply-utils.h
index 9cdebfd..caa54df 100644
--- a/src/ply-utils.h
+++ b/src/ply-utils.h
@@ -61,6 +61,9 @@ double ply_get_timestamp (void);
void ply_save_errno (void);
void ply_restore_errno (void);
+
+bool ply_directory_exists (const char *dir);
+bool ply_file_exists (const char *file);
#endif
#endif /* PLY_UTILS_H */