fs/glue/StandardDirectory: Add standard directories for macOS
This commit is contained in:
		 Camille Scholtz
					Camille Scholtz
				
			
				
					committed by
					
						 Max Kellermann
						Max Kellermann
					
				
			
			
				
	
			
			
			 Max Kellermann
						Max Kellermann
					
				
			
						parent
						
							86ab4bc62c
						
					
				
				
					commit
					30e1cbbcba
				
			
							
								
								
									
										1
									
								
								NEWS
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								NEWS
									
									
									
									
									
								
							| @@ -2,6 +2,7 @@ ver 0.24.1 (not yet released) | |||||||
| * output | * output | ||||||
|   - sndio: fix rounding error in volume calculation |   - sndio: fix rounding error in volume calculation | ||||||
| * log: include year in time stamp | * log: include year in time stamp | ||||||
|  | * macOS: implement standard directories | ||||||
| * fix build failure in the "id3tag" Meson subproject | * fix build failure in the "id3tag" Meson subproject | ||||||
| * doc: use "sphinx_rtd_theme" only if it is installed | * doc: use "sphinx_rtd_theme" only if it is installed | ||||||
|  |  | ||||||
|   | |||||||
| @@ -38,7 +38,7 @@ | |||||||
| #include "Main.hxx" | #include "Main.hxx" | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #ifdef USE_XDG | #if defined(USE_XDG) || defined(__APPLE__) | ||||||
| #include "Version.h" // for PACKAGE_NAME | #include "Version.h" // for PACKAGE_NAME | ||||||
| #define APP_FILENAME PATH_LITERAL(PACKAGE_NAME) | #define APP_FILENAME PATH_LITERAL(PACKAGE_NAME) | ||||||
| static constexpr Path app_filename = Path::FromFS(APP_FILENAME); | static constexpr Path app_filename = Path::FromFS(APP_FILENAME); | ||||||
| @@ -260,6 +260,14 @@ GetUserConfigDir() noexcept | |||||||
| 			return fallback; | 			return fallback; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	return nullptr; | ||||||
|  | #elif defined(__APPLE__) | ||||||
|  | 	if (const auto home = GetHomeDir(); !home.IsNull()) { | ||||||
|  | 		auto fallback = home / Path::FromFS("Library/Application Support"); | ||||||
|  | 		if (IsValidDir(fallback)) | ||||||
|  | 			return fallback; | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	return nullptr; | 	return nullptr; | ||||||
| #else | #else | ||||||
| 	return nullptr; | 	return nullptr; | ||||||
| @@ -271,6 +279,14 @@ GetUserMusicDir() noexcept | |||||||
| { | { | ||||||
| #if defined(_WIN32) | #if defined(_WIN32) | ||||||
| 	return GetStandardDir(CSIDL_MYMUSIC); | 	return GetStandardDir(CSIDL_MYMUSIC); | ||||||
|  | #elif defined(__APPLE__) | ||||||
|  | 	if (const auto home = GetHomeDir(); !home.IsNull()) { | ||||||
|  | 		auto fallback = home / Path::FromFS("Music"); | ||||||
|  | 		if (IsValidDir(fallback)) | ||||||
|  | 			return fallback; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	return nullptr; | ||||||
| #elif defined(USE_XDG) | #elif defined(USE_XDG) | ||||||
| 	return GetUserDir("XDG_MUSIC_DIR"); | 	return GetUserDir("XDG_MUSIC_DIR"); | ||||||
| #elif defined(ANDROID) | #elif defined(ANDROID) | ||||||
| @@ -296,6 +312,13 @@ GetUserCacheDir() noexcept | |||||||
| 		    IsValidDir(fallback)) | 		    IsValidDir(fallback)) | ||||||
| 			return fallback; | 			return fallback; | ||||||
|  |  | ||||||
|  | 	return nullptr; | ||||||
|  | #elif defined(__APPLE__) | ||||||
|  | 	if (const auto home = GetHomeDir(); !home.IsNull()) | ||||||
|  | 		if (auto fallback = home / Path::FromFS("Library/Caches"); | ||||||
|  | 		    IsValidDir(fallback)) | ||||||
|  | 			return fallback; | ||||||
|  |  | ||||||
| 	return nullptr; | 	return nullptr; | ||||||
| #elif defined(ANDROID) | #elif defined(ANDROID) | ||||||
| 	return context->GetCacheDir(Java::GetEnv()); | 	return context->GetCacheDir(Java::GetEnv()); | ||||||
| @@ -307,7 +330,7 @@ GetUserCacheDir() noexcept | |||||||
| AllocatedPath | AllocatedPath | ||||||
| GetAppCacheDir() noexcept | GetAppCacheDir() noexcept | ||||||
| { | { | ||||||
| #ifdef USE_XDG | #if defined(USE_XDG) || defined(__APPLE__) | ||||||
| 	if (const auto user_dir = GetUserCacheDir(); !user_dir.IsNull()) { | 	if (const auto user_dir = GetUserCacheDir(); !user_dir.IsNull()) { | ||||||
| 		auto dir = user_dir / app_filename; | 		auto dir = user_dir / app_filename; | ||||||
| 		CreateDirectoryNoThrow(dir); | 		CreateDirectoryNoThrow(dir); | ||||||
| @@ -329,6 +352,13 @@ GetUserRuntimeDir() noexcept | |||||||
| 	if (const auto path = GetExistingEnvDirectory("XDG_RUNTIME_DIR"); | 	if (const auto path = GetExistingEnvDirectory("XDG_RUNTIME_DIR"); | ||||||
| 	    path != nullptr) | 	    path != nullptr) | ||||||
| 		return AllocatedPath{path}; | 		return AllocatedPath{path}; | ||||||
|  |  | ||||||
|  | #elif defined(__APPLE__) | ||||||
|  | 	if (const auto home = GetHomeDir(); !home.IsNull()) { | ||||||
|  | 		auto fallback = home / Path::FromFS("Library/Application Support"); | ||||||
|  | 		if (IsValidDir(fallback)) | ||||||
|  | 			return fallback; | ||||||
|  | 	} | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| 	return nullptr; | 	return nullptr; | ||||||
| @@ -345,7 +375,7 @@ GetAppRuntimeDir() noexcept | |||||||
| 			return AllocatedPath::FromFS(dir); | 			return AllocatedPath::FromFS(dir); | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #ifdef USE_XDG | #if defined(USE_XDG_) || defined(__APPLE__) | ||||||
| 	if (const auto user_dir = GetUserRuntimeDir(); !user_dir.IsNull()) { | 	if (const auto user_dir = GetUserRuntimeDir(); !user_dir.IsNull()) { | ||||||
| 		auto dir = user_dir / app_filename; | 		auto dir = user_dir / app_filename; | ||||||
| 		CreateDirectoryNoThrow(dir); | 		CreateDirectoryNoThrow(dir); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user