-
Notifications
You must be signed in to change notification settings - Fork 498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce App Directory Path #572
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
64471ab
Introduce app directory path concept
dcvz 4c4c18d
macos: Remove hacky way of using applicaiton directory
dcvz ea28e40
Update the new SaveManager
dcvz 13482dc
Address stack user after return
dcvz d74a1cd
Remove unecessary property
dcvz 33e91b4
Merge branch 'develop' into feature/app-file-path
dcvz 5b65a1e
Use std::string for filepath
dcvz a2a861e
Merge branch 'develop' into feature/app-file-path
dcvz eb2bd0d
Improve clang specific detections
dcvz 477f400
Use new path system for imgui files
dcvz c6491a5
Improve helper for getting relative paths
dcvz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use
strdup(imguiIniPath.c_str());
andstrdup(imguiLogPath.c_str());
here.