]> git.lyx.org Git - lyx.git/blobdiff - src/support/FileInfo.h
lyx-devel.diff
[lyx.git] / src / support / FileInfo.h
index 47802465ba2f647fa664ffdb55b4f30cdc025a8e..8223c15c7d68199fbcc78ca4de6429c6198ed5f0 100644 (file)
 
 #include <ctime>
 
-#include <unistd.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-
+#include <unistd.h>
+#include <boost/utility.hpp>
 #include "LString.h"
 
-/** Use objects of this class to get information about files. */
-class FileInfo {
+/** Use objects of this class to get information about files.
+ */
+class FileInfo : public noncopyable {
 public:
        ///
        FileInfo();
@@ -59,7 +60,7 @@ public:
        char typeLetter() const;
        
        /// builds 'rwx' string describing file access rights
-       void flagRWX(unsigned short i, char * szString) const;
+       void flagRWX(mode_t i, char * szString) const;
        
        /// updates mode string to match suid/sgid/sticky bits
        void setSticky(char * szString) const;
@@ -90,21 +91,25 @@ public:
        
        /// Permission flags
        enum perm_test {
-               rperm = R_OK, // test for read permission
-               wperm = W_OK, // test for write permission
-               xperm = X_OK, // test for execute (search) permission
-               eperm = F_OK  // test for existence of file
+               /// test for read permission
+               rperm = R_OK,
+               /// test for write permission
+               wperm = W_OK,
+               /// test for execute (search) permission
+               xperm = X_OK,
+               /// test for existence of file
+               eperm = F_OK
        };
        /// Test whether the current user has a given set of permissions
-       bool access(int p);
+       bool access(int p) const;
        /// Is the file writable for the current user?
-       bool writable() { return access(FileInfo::wperm); }
+       bool writable() const { return access(FileInfo::wperm); }
        /// Is the file readable for the current user?
-       bool readable() { return access(FileInfo::rperm); }
+       bool readable() const { return access(FileInfo::rperm); }
        /// Is the file executable for the current user?
-       bool executable() { return access(FileInfo::xperm); }
+       bool executable() const { return access(FileInfo::xperm); }
        /// Does the file exist?
-       bool exist() { return access(FileInfo::eperm); }
+       bool exist() const { return access(FileInfo::eperm); }
        ///
        bool isLink() const;
        ///
@@ -122,7 +127,7 @@ public:
        ///
        int getError() const;
        ///
-       enum {
+       enum Err {
                ///
                NoErr = -1
        };