]> git.mxchange.org Git - simgear.git/blobdiff - simgear/misc/sg_path.hxx
Fix VS2010 lack of fminf
[simgear.git] / simgear / misc / sg_path.hxx
index 2cade3206628555fa46ebeb8994609fec3a58109..3e5c22fe3c016e9739f5a546269355db36681305 100644 (file)
@@ -57,10 +57,10 @@ public:
       bool read : 1;
       bool write : 1;
     };
-    typedef Permissions (*PermissonChecker)(const SGPath&);
+    typedef Permissions (*PermissionChecker)(const SGPath&);
 
     /** Default constructor */
-    explicit SGPath(PermissonChecker validator = NULL);
+    explicit SGPath(PermissionChecker validator = NULL);
 
     /** Copy contructor */
     SGPath(const SGPath& p);
@@ -71,7 +71,7 @@ public:
      * Construct a path based on the starting path provided.
      * @param p initial path
      */
-    SGPath( const std::string& p, PermissonChecker validator = NULL );
+    SGPath( const std::string& p, PermissionChecker validator = NULL );
 
     /**
      * Construct a path based on the starting path provided and a relative subpath
@@ -80,7 +80,7 @@ public:
      */
     SGPath( const SGPath& p,
             const std::string& r,
-            PermissonChecker validator = NULL );
+            PermissionChecker validator = NULL );
 
     /** Destructor */
     ~SGPath();
@@ -95,8 +95,8 @@ public:
     bool operator==(const SGPath& other) const;
     bool operator!=(const SGPath& other) const;
 
-    void setPermissonChecker(PermissonChecker validator);
-    PermissonChecker getPermissonChecker() const;
+    void setPermissionChecker(PermissionChecker validator);
+    PermissionChecker getPermissionChecker() const;
 
     /**
      * Set if file information (exists, type, mod-time) is cached or
@@ -206,9 +206,12 @@ public:
 
     /**
      * Create the designated directory.
+     *
+     * @param mode Permissions. See:
+     *    http://en.wikipedia.org/wiki/File_system_permissions#Numeric_notation
      * @return 0 on success, or <0 on failure.
      */
-    int create_dir(mode_t mode);
+    int create_dir(mode_t mode = 0755);
 
     /**
      * Check if reading file is allowed. Readabilty does not imply the existance
@@ -257,6 +260,18 @@ public:
      */
     bool rename(const SGPath& newName);
 
+    enum StandardLocation
+    {
+      HOME,
+      DESKTOP,
+      DOWNLOADS,
+      DOCUMENTS,
+      PICTURES
+    };
+
+    static SGPath standardLocation( StandardLocation type,
+                                    const SGPath& def = SGPath() );
+
     /**
      * Get a path stored in the environment variable with the given \a name.
      *
@@ -280,6 +295,7 @@ public:
      * Get path to the user's documents directory
      */
     static SGPath documents(const SGPath& def = SGPath());
+
 private:
 
     void fix();
@@ -288,7 +304,7 @@ private:
     void checkAccess() const;
 
     std::string path;
-    PermissonChecker _permission_checker;
+    PermissionChecker _permission_checker;
 
     mutable bool _cached : 1;
     mutable bool _rwCached : 1;