mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-08-12 09:55:33 +02:00
Form normalized paths from absolutes with ObjC
This commit is contained in:
parent
9b9f4658dd
commit
8231f52d6f
1 changed files with 7 additions and 7 deletions
|
@ -7,7 +7,8 @@
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
#import "filesystemImpl.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)]
|
#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) {
|
std::string filesystemImpl::normalizePath(const char *path, bool preferred, bool absolute) {
|
||||||
NSString *nspath = PATHTONS(path);
|
NSString *nspath = [NSURL fileURLWithPath: PATHTONS(path)].URLByStandardizingPath.path;
|
||||||
if (!nspath.isAbsolutePath && absolute) {
|
NSString *pwd = [NSString stringWithFormat:@"%@/", NSFileManager.defaultManager.currentDirectoryPath];
|
||||||
nspath = [NSURL fileURLWithPath: nspath].URLByStandardizingPath.path;
|
if (!absolute) {
|
||||||
}
|
nspath = [nspath stringByReplacingOccurrencesOfString:pwd withString:@""];
|
||||||
else {
|
|
||||||
nspath = nspath.stringByStandardizingPath;
|
|
||||||
}
|
}
|
||||||
|
Debug() << nspath.UTF8String;
|
||||||
return std::string(NSTOPATH(nspath));
|
return std::string(NSTOPATH(nspath));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue