mirror of
				https://github.com/Zelda64Recomp/Zelda64Recomp.git
				synced 2025-10-30 08:03:03 +00:00 
			
		
		
		
	Use Application Support directory on macOS. (#553)
	
		
			
	
		
	
	
		
	
		
			Some checks failed
		
		
	
	
		
			
				
	
				validate-internal / build (push) Has been cancelled
				
			
		
		
	
	
				
					
				
			
		
			Some checks failed
		
		
	
	validate-internal / build (push) Has been cancelled
				
			This commit is contained in:
		
							parent
							
								
									3d3524ffe7
								
							
						
					
					
						commit
						fd16c379ff
					
				
					 4 changed files with 19 additions and 0 deletions
				
			
		|  | @ -122,6 +122,7 @@ You'll probably also want to change the default behavior so that you don't need | |||
| #### Where is the savefile stored? | ||||
| - Windows: `%LOCALAPPDATA%\Zelda64Recompiled\saves` | ||||
| - Linux: `~/.config/Zelda64Recompiled/saves` | ||||
| - macOS: `~/Library/Application Support/Zelda64Recompiled/saves` | ||||
| 
 | ||||
| #### How do I choose a different ROM? | ||||
| **You don't.** This project is **only** a port of Majora's Mask (and Ocarina of Time in the future), and it will only accept one specific ROM: the US version of the N64 release of Majora's Mask. ROMs in formats other than .z64 will be automatically converted, as long as it is the correct ROM. **It is not an emulator and it cannot run any arbitrary ROM.**  | ||||
|  |  | |||
|  | @ -3,6 +3,7 @@ | |||
| 
 | ||||
| #include <functional> | ||||
| #include <filesystem> | ||||
| #include <optional> | ||||
| 
 | ||||
| namespace zelda64 { | ||||
|     std::filesystem::path get_asset_path(const char* asset); | ||||
|  | @ -12,6 +13,7 @@ namespace zelda64 { | |||
| // Apple specific methods that usually require Objective-C. Implemented in support_apple.mm.
 | ||||
| #ifdef __APPLE__ | ||||
|     void dispatch_on_ui_thread(std::function<void()> func); | ||||
|     std::optional<std::filesystem::path> get_application_support_directory(); | ||||
|     std::filesystem::path get_bundle_resource_directory(); | ||||
|     std::filesystem::path get_bundle_directory(); | ||||
| #endif | ||||
|  |  | |||
|  | @ -162,6 +162,13 @@ std::filesystem::path zelda64::get_app_folder_path() { | |||
|        return std::filesystem::path{getenv("APP_FOLDER_PATH")}; | ||||
|    } | ||||
| 
 | ||||
| #if defined(__APPLE__) | ||||
|    const auto supportdir = zelda64::get_application_support_directory(); | ||||
|    if (supportdir) { | ||||
|        return *supportdir / zelda64::program_id; | ||||
|    } | ||||
| #endif | ||||
| 
 | ||||
|    const char *homedir; | ||||
| 
 | ||||
|    if ((homedir = getenv("HOME")) == nullptr) { | ||||
|  |  | |||
|  | @ -12,6 +12,15 @@ namespace zelda64 { | |||
|         }); | ||||
|     } | ||||
| 
 | ||||
|     std::optional<std::filesystem::path> get_application_support_directory() { | ||||
|         NSArray *dirs = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); | ||||
|         if ([dirs count] > 0) { | ||||
|             NSString *dir = [dirs firstObject]; | ||||
|             return std::filesystem::path([dir UTF8String]); | ||||
|         } | ||||
|         return std::nullopt; | ||||
|     } | ||||
| 
 | ||||
|     std::filesystem::path get_bundle_resource_directory() { | ||||
|         NSString *bundlePath = [[NSBundle mainBundle] resourcePath]; | ||||
|         return std::filesystem::path([bundlePath UTF8String]); | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 squidbus
						squidbus