commit 381e222b
Merge pull request #16 from sago007/MacNoCore
Mac no core
Changed files
| M | CMakeLists.txt before |
| M | README.md before |
| M | sago/platform_folders.cpp before |
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 519db44..50979ce 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -39,25 +39,6 @@ endif()
# cxx_nullptr exists in v3.1
target_compile_features(platform_folders PRIVATE cxx_nullptr)
-# Apple requires linking to CoreServices
-# Check sys name instead of "APPLE" for cross-compilation
-if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
- # Find the framework
- # ref: https://developer.apple.com/library/content/documentation/MacOSX/Conceptual/OSX_Technology_Overview/SystemFrameworks/SystemFrameworks.html
- find_library(_CoreServices_FRAMEWORK
- NAMES "CoreServices.framework" "CoreServices"
- PATH_SUFFIXES "CoreServices"
- PATHS "/System/Library/Frameworks"
- )
- # Make sure it was found
- if(NOT _CoreServices_FRAMEWORK)
- message(FATAL_ERROR "Could not find the CoreServices framework!")
- endif()
- # Link to the CoreServices framework. This also sets the correct linking options
- # "If the library file is in a Mac OSX framework, the Headers directory of the framework will also be processed as a usage requirement."
- target_link_libraries(platform_folders PRIVATE "${_CoreServices_FRAMEWORK}")
-endif()
-
# Cmake's find_package search path is different based on the system
# See https://cmake.org/cmake/help/latest/command/find_package.html for the list
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
diff --git a/README.md b/README.md
index 4e9d207..4978a0f 100644
--- a/README.md
+++ b/README.md
@@ -34,7 +34,9 @@ It should work on any Unix system that has the following headers available: `pwd
### macOS
-Uses the deprecated FSFindFolder (there is no C++ alternative), which requires the CoreServices framework during linking.
+Version 4.0.0 and forward uses hardcoded values for the directories on Mac OS X. Unlike the other operating systems the folders cannot be moved on a Mac and the translation is done in the UI.
+The versions 2.X and 3.X uses the deprecated FSFindFolder, which requires the CoreServices framework during linking.
+Version 1.X simple used the XDG specification.
## Usage
@@ -51,13 +53,13 @@ target_link_libraries(EXEORLIBNAME PRIVATE sago::platform_folders)
```
Alternatively, you can just copy the [sago](https://github.com/sago007/PlatformFolders/tree/master/sago) folder into your program and manually link everything.
-If you use the last option: Remember to link to the CoreServices lib when compiling on Mac. This typically means passing "-framework CoreServices" during the linking phase.
+If you use the last option and are using a library version from before 4.0.0: Remember to link to the CoreServices lib when compiling on Mac. This typically means passing "-framework CoreServices" during the linking phase.
### Building
**Notes:**
-* macOS requires the CoreServices framework during linking.
+* Until 4.0.0 macOS required the CoreServices framework during linking.
* If you don't want to install, remove the `--target install` command.
Linux/macOS:
diff --git a/sago/platform_folders.cpp b/sago/platform_folders.cpp
index 93b2941..f4e699e 100644
--- a/sago/platform_folders.cpp
+++ b/sago/platform_folders.cpp
@@ -131,21 +131,6 @@ static std::string GetAppDataLocal() {
return GetKnownWindowsFolder(FOLDERID_LocalAppData, "LocalAppData could not be found");
}
#elif defined(__APPLE__)
-#include <CoreServices/CoreServices.h>
-
-static std::string GetMacFolder(OSType folderType, const char* errorMsg) {
- std::string ret;
- FSRef ref;
- char path[PATH_MAX];
- OSStatus err = FSFindFolder( kUserDomain, folderType, kCreateFolder, &ref );
- if (err != noErr) {
- throw std::runtime_error(errorMsg);
- }
- FSRefMakePath( &ref, (UInt8*)&path, PATH_MAX );
- ret = path;
- return ret;
-}
-
#else
#include <map>
#include <fstream>
@@ -209,7 +194,7 @@ std::string getDataHome() {
#ifdef _WIN32
return GetAppData();
#elif defined(__APPLE__)
- return GetMacFolder(kApplicationSupportFolderType, "Failed to find the Application Support Folder");
+ return getHome()+"/Library/Application Support";
#else
return getLinuxFolderDefault("XDG_DATA_HOME", ".local/share");
#endif
@@ -219,7 +204,7 @@ std::string getConfigHome() {
#ifdef _WIN32
return GetAppData();
#elif defined(__APPLE__)
- return GetMacFolder(kApplicationSupportFolderType, "Failed to find the Application Support Folder");
+ return getHome()+"/Library/Application Support";
#else
return getLinuxFolderDefault("XDG_CONFIG_HOME", ".config");
#endif
@@ -229,7 +214,7 @@ std::string getCacheDir() {
#ifdef _WIN32
return GetAppDataLocal();
#elif defined(__APPLE__)
- return GetMacFolder(kCachedDataFolderType, "Failed to find the Application Support Folder");
+ return getHome()+"/Library/Caches";
#else
return getLinuxFolderDefault("XDG_CACHE_HOME", ".cache");
#endif
@@ -319,7 +304,7 @@ std::string PlatformFolders::getDocumentsFolder() const {
#ifdef _WIN32
return GetKnownWindowsFolder(FOLDERID_Documents, "Failed to find My Documents folder");
#elif defined(__APPLE__)
- return GetMacFolder(kDocumentsFolderType, "Failed to find Documents Folder");
+ return getHome()+"/Documents";
#else
return data->folders["XDG_DOCUMENTS_DIR"];
#endif
@@ -329,7 +314,7 @@ std::string PlatformFolders::getDesktopFolder() const {
#ifdef _WIN32
return GetKnownWindowsFolder(FOLDERID_Desktop, "Failed to find Desktop folder");
#elif defined(__APPLE__)
- return GetMacFolder(kDesktopFolderType, "Failed to find Desktop folder");
+ return getHome()+"/Desktop";
#else
return data->folders["XDG_DESKTOP_DIR"];
#endif
@@ -339,7 +324,7 @@ std::string PlatformFolders::getPicturesFolder() const {
#ifdef _WIN32
return GetKnownWindowsFolder(FOLDERID_Pictures, "Failed to find My Pictures folder");
#elif defined(__APPLE__)
- return GetMacFolder(kPictureDocumentsFolderType, "Failed to find Picture folder");
+ return getHome()+"/Pictures";
#else
return data->folders["XDG_PICTURES_DIR"];
#endif
@@ -359,7 +344,7 @@ std::string PlatformFolders::getDownloadFolder1() const {
#ifdef _WIN32
return GetKnownWindowsFolder(FOLDERID_Downloads, "Failed to find My Downloads folder");
#elif defined(__APPLE__)
- return GetMacFolder(kDownloadsFolderType, "Failed to find Download folder");
+ return getHome()+"/Downloads";
#else
return data->folders["XDG_DOWNLOAD_DIR"];
#endif
@@ -369,7 +354,7 @@ std::string PlatformFolders::getMusicFolder() const {
#ifdef _WIN32
return GetKnownWindowsFolder(FOLDERID_Music, "Failed to find My Music folder");
#elif defined(__APPLE__)
- return GetMacFolder(kMusicDocumentsFolderType, "Failed to find Music folder");
+ return getHome()+"/Music";
#else
return data->folders["XDG_MUSIC_DIR"];
#endif
@@ -379,7 +364,7 @@ std::string PlatformFolders::getVideoFolder() const {
#ifdef _WIN32
return GetKnownWindowsFolder(FOLDERID_Videos, "Failed to find My Video folder");
#elif defined(__APPLE__)
- return GetMacFolder(kMovieDocumentsFolderType, "Failed to find Movie folder");
+ return getHome()+"/Movies";
#else
return data->folders["XDG_VIDEOS_DIR"];
#endif
@@ -391,7 +376,7 @@ std::string PlatformFolders::getSaveGamesFolder1() const {
//Data that should not be user accessible should be placed under GetDataHome() instead
return GetKnownWindowsFolder(FOLDERID_Documents, "Failed to find My Documents folder")+"\\My Games";
#elif defined(__APPLE__)
- return GetMacFolder(kApplicationSupportFolderType, "Failed to find Application Support Folder");
+ return getHome()+"/Library/Application Support";
#else
return getDataHome();
#endif