]> git.mxchange.org Git - simgear.git/blobdiff - simgear/misc/sg_path.cxx
Update doxgen config and some comments.
[simgear.git] / simgear / misc / sg_path.cxx
index e38c67ee1b484f6b2c459708dc849661bbe2ce2c..3c6e5b6b6693b8ebbc3d3e75bc21c7e3f99126ba 100644 (file)
@@ -75,28 +75,16 @@ static SGPath pathForCSIDL(int csidl, const SGPath& def)
 
        char path[MAX_PATH];
        if (SHGetSpecialFolderPath(0, path, csidl, false)) {
-               return SGPath(path, def.getPermissonChecker());
+               return SGPath(path, def.getPermissionChecker());
        }
 
        return def;
 }
 #elif __APPLE__
-#include <CoreServices/CoreServices.h>
 
-//------------------------------------------------------------------------------
-static SGPath appleSpecialFolder(OSType type, const SGPath& def)
-{
-  FSRef ref;
-  OSErr err = FSFindFolder(kUserDomain, kDesktopFolderType, false, &ref);
-  if( err )
-    return def;
-
-  unsigned char path[1024];
-  if( FSRefMakePath(&ref, path, 1024) != noErr )
-    return def;
+// defined in CocoaHelpers.mm
+SGPath appleSpecialFolder(int dirType, int domainMask, const SGPath& def);
 
-  return SGPath((const char*) path, def.getPermissonChecker());
-}
 #else
 static SGPath getXDGDir( const std::string& name,
                          const SGPath& def,
@@ -131,7 +119,7 @@ static SGPath getXDGDir( const std::string& name,
       return SGPath::home(def)
            / simgear::strutils::unescape(line.substr(HOME.length()));
 
-    return SGPath(line, def.getPermissonChecker());
+    return SGPath(line, def.getPermissionChecker());
   }
 
   if( def.isNull() )
@@ -160,7 +148,7 @@ SGPath::fix()
 
 
 // default constructor
-SGPath::SGPath(PermissonChecker validator)
+SGPath::SGPath(PermissionChecker validator)
     : path(""),
     _permission_checker(validator),
     _cached(false),
@@ -171,7 +159,7 @@ SGPath::SGPath(PermissonChecker validator)
 
 
 // create a path based on "path"
-SGPath::SGPath( const std::string& p, PermissonChecker validator )
+SGPath::SGPath( const std::string& p, PermissionChecker validator )
     : path(p),
     _permission_checker(validator),
     _cached(false),
@@ -184,7 +172,7 @@ SGPath::SGPath( const std::string& p, PermissonChecker validator )
 // create a path based on "path" and a "subpath"
 SGPath::SGPath( const SGPath& p,
                 const std::string& r,
-                PermissonChecker validator )
+                PermissionChecker validator )
     : path(p.path),
     _permission_checker(validator),
     _cached(false),
@@ -240,14 +228,14 @@ void SGPath::set( const string& p ) {
 }
 
 //------------------------------------------------------------------------------
-void SGPath::setPermissonChecker(PermissonChecker validator)
+void SGPath::setPermissionChecker(PermissionChecker validator)
 {
   _permission_checker = validator;
   _rwCached = false;
 }
 
 //------------------------------------------------------------------------------
-SGPath::PermissonChecker SGPath::getPermissonChecker() const
+SGPath::PermissionChecker SGPath::getPermissionChecker() const
 {
   return _permission_checker;
 }
@@ -728,16 +716,16 @@ SGPath SGPath::standardLocation(StandardLocation type, const SGPath& def)
     case PICTURES:
       return pathForCSIDL(CSIDL_MYPICTURES, def);
 #elif __APPLE__
+      // since this is C++, we can't include NSPathUtilities.h to access the enum
+      // values, so hard-coding them here (they are stable, don't worry)
     case DOWNLOADS:
-      if( !def.isNull() )
-        return def;
-      // There is no special downloads folder -> just use the desktop
+      return appleSpecialFolder(15, 1, def);
     case DESKTOP:
-      return appleSpecialFolder(kDesktopFolderType, def);
+      return appleSpecialFolder(12, 1, def);
     case DOCUMENTS:
-      return appleSpecialFolder(kDocumentsFolderType, def);
+      return appleSpecialFolder(9, 1, def);
     case PICTURES:
-      return appleSpecialFolder(kPictureDocumentsFolderType, def);
+      return appleSpecialFolder(19, 1, def);
 #else
     case DESKTOP:
       return getXDGDir("DESKTOP", def, "Desktop");