diff --git a/src/filesystem/filesystemImplApple.mm b/src/filesystem/filesystemImplApple.mm index 66f35f80..760cb0e6 100644 --- a/src/filesystem/filesystemImplApple.mm +++ b/src/filesystem/filesystemImplApple.mm @@ -7,7 +7,8 @@ #import #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)); }