]> source.dussan.org Git - tigervnc.git/commitdiff
[Development] os: introduce new function called "fileexists"
authorAdam Tkac <atkac@redhat.com>
Mon, 7 Feb 2011 10:46:45 +0000 (10:46 +0000)
committerAdam Tkac <atkac@redhat.com>
Mon, 7 Feb 2011 10:46:45 +0000 (10:46 +0000)
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4255 3789f03b-4d11-0410-bbf8-ca57d06f2519

common/os/os.cxx
common/os/os.h

index c08b57289c46adef28511779e008a48022b138ca..46470eaad3a67e8036abadd4e937da9c831d0440 100644 (file)
@@ -85,3 +85,13 @@ int getvnchomedir(char **dirp)
        return 0;
 }
 
+int fileexists(char *file)
+{
+#ifdef WIN32
+  return (GetFileAttributes(file) == INVALID_FILE_ATTRIBUTES) ? -1 : 0;
+#else
+  return access(file, R_OK);
+#endif
+}
+
+
index d011764e849f460360ad6b1c2d4bf9e755f5f760..1847a494acdb1626af563a9957aa7d3032557a96 100644 (file)
  */
 int getvnchomedir(char **dirp);
 
+/*
+ * Check if the file exists
+ *
+ * Returns:
+ * 0 - Success
+ * -1 - Failure
+ */
+int fileexists(char *file);
+
 #endif /* OS_OS_H */