mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-07-24 16:45:21 +02:00
Form normalized paths from absolutes with ObjC
This commit is contained in:
parent
dffbe682f1
commit
45e224626e
1 changed files with 7 additions and 7 deletions
|
@ -7,7 +7,8 @@
|
|||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "filesystemImpl.h"
|
||||
#import "exception.h"
|
||||
#import "util/exception.h"
|
||||
#import "util/debugwriter.h"
|
||||
|
||||
#define PATHTONS(str) [NSFileManager.defaultManager stringWithFileSystemRepresentation:str length:strlen(str)]
|
||||
|
||||
|
@ -40,13 +41,12 @@ std::string filesystemImpl::getCurrentDirectory() {
|
|||
}
|
||||
|
||||
std::string filesystemImpl::normalizePath(const char *path, bool preferred, bool absolute) {
|
||||
NSString *nspath = PATHTONS(path);
|
||||
if (!nspath.isAbsolutePath && absolute) {
|
||||
nspath = [NSURL fileURLWithPath: nspath].URLByStandardizingPath.path;
|
||||
}
|
||||
else {
|
||||
nspath = nspath.stringByStandardizingPath;
|
||||
NSString *nspath = [NSURL fileURLWithPath: PATHTONS(path)].URLByStandardizingPath.path;
|
||||
NSString *pwd = [NSString stringWithFormat:@"%@/", NSFileManager.defaultManager.currentDirectoryPath];
|
||||
if (!absolute) {
|
||||
nspath = [nspath stringByReplacingOccurrencesOfString:pwd withString:@""];
|
||||
}
|
||||
Debug() << nspath.UTF8String;
|
||||
return std::string(NSTOPATH(nspath));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue