]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
add new functions that check if a file or dir exists
authorRay Strode <rstrode@redhat.com>
Wed, 23 May 2007 19:32:06 +0000 (15:32 -0400)
committerRay Strode <rstrode@redhat.com>
Wed, 23 May 2007 19:32:06 +0000 (15:32 -0400)
src/ply-utils.c
src/ply-utils.h

index 5b531b73fc10d40c9fb92f002d77920cfff2b10a..a3f29a09457f056de796f964084f14816eb8b2fa 100644 (file)
@@ -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: */
index 9cdebfd0138d4f9d8e7b1e2d45ccc17b89c23f0c..caa54df8522ac7063522548e3e3265c8d48b9ebc 100644 (file)
@@ -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 */