-
Notifications
You must be signed in to change notification settings - Fork 498
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Introduce app directory path concept * macos: Remove hacky way of using applicaiton directory * Update the new SaveManager * Address stack user after return * Remove unecessary property * Use std::string for filepath * Improve clang specific detections * Use new path system for imgui files * Improve helper for getting relative paths
- Loading branch information
Showing
16 changed files
with
186 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// | ||
// OSXFolderManager.h | ||
// libultraship | ||
// | ||
// Created by David Chavez on 28.06.22. | ||
// | ||
|
||
#ifndef OSXFolderManager_h | ||
#define OSXFolderManager_h | ||
|
||
#include <stdio.h> | ||
namespace Ship { | ||
enum { | ||
NSApplicationDirectory = 1, | ||
NSDemoApplicationDirectory, | ||
NSDeveloperApplicationDirectory, | ||
NSAdminApplicationDirectory, | ||
NSLibraryDirectory, | ||
NSDeveloperDirectory, | ||
NSUserDirectory, | ||
NSDocumentationDirectory, | ||
NSDocumentDirectory, | ||
NSCoreServiceDirectory, | ||
NSAutosavedInformationDirectory = 11, | ||
NSDesktopDirectory = 12, | ||
NSCachesDirectory = 13, | ||
NSApplicationSupportDirectory = 14, | ||
NSDownloadsDirectory = 15, | ||
NSInputMethodsDirectory = 16, | ||
NSMoviesDirectory = 17, | ||
NSMusicDirectory = 18, | ||
NSPicturesDirectory = 19, | ||
NSPrinterDescriptionDirectory = 20, | ||
NSSharedPublicDirectory = 21, | ||
NSPreferencePanesDirectory = 22, | ||
NSApplicationScriptsDirectory = 23, | ||
NSItemReplacementDirectory = 99, | ||
NSAllApplicationsDirectory = 100, | ||
NSAllLibrariesDirectory = 101, | ||
NSTrashDirectory = 102 | ||
}; | ||
typedef unsigned long SearchPathDirectory; | ||
|
||
enum { | ||
NSUserDomainMask = 1, // user's home directory --- place to install user's personal items (~) | ||
NSLocalDomainMask = 2, // local to the current machine --- place to install items available to everyone on this machine (/Library) | ||
NSNetworkDomainMask = 4, // publically available location in the local area network --- place to install items available on the network (/Network) | ||
NSSystemDomainMask = 8, // provided by Apple, unmodifiable (/System) | ||
NSAllDomainsMask = 0x0ffff // all domains: all of the above and future items | ||
}; | ||
typedef unsigned long SearchPathDomainMask; | ||
|
||
class FolderManager { | ||
public: | ||
const char *pathForDirectory(SearchPathDirectory directory, SearchPathDomainMask domainMask); | ||
const char *pathForDirectoryAppropriateForItemAtPath(SearchPathDirectory directory, SearchPathDomainMask domainMask, const char *itemPath, bool create = false); | ||
}; | ||
}; | ||
|
||
#endif /* OSXFolderManager_h */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// | ||
// OSXFolderManager.m | ||
// libultraship | ||
// | ||
// Created by David Chavez on 28.06.22. | ||
// | ||
|
||
#include "OSXFolderManager.h" | ||
#import <Foundation/Foundation.h> | ||
|
||
using namespace Ship; | ||
|
||
const char * FolderManager::pathForDirectory(SearchPathDirectory directory, SearchPathDomainMask domainMask) { | ||
NSFileManager *fileManager = [NSFileManager defaultManager]; | ||
NSArray *URLs = [fileManager URLsForDirectory:(NSSearchPathDirectory)directory inDomains:domainMask]; | ||
if (URLs.count == 0) return NULL; | ||
|
||
NSURL *URL = [URLs objectAtIndex:0]; | ||
NSString *path = URL.path; | ||
|
||
// `fileSystemRepresentation` on an `NSString` gives a path suitable for POSIX APIs | ||
return path.fileSystemRepresentation; | ||
} | ||
|
||
const char * FolderManager::pathForDirectoryAppropriateForItemAtPath(SearchPathDirectory directory, | ||
SearchPathDomainMask domainMask, const char *itemPath, bool create) { | ||
|
||
NSFileManager *fileManager = [NSFileManager defaultManager]; | ||
NSString *nsPath = [fileManager stringWithFileSystemRepresentation:itemPath length:strlen(itemPath)]; | ||
NSURL *itemURL = (nsPath ? [NSURL fileURLWithPath:nsPath] : nil); | ||
|
||
NSURL *URL = [fileManager URLForDirectory:(NSSearchPathDirectory)directory | ||
inDomain:domainMask | ||
appropriateForURL:itemURL | ||
create:create error:NULL]; | ||
return URL.path.fileSystemRepresentation; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.