@@ -124,26 +124,26 @@ of_stat(OFString *path, of_stat_t *buffer) { #ifdef _WIN32 return _wstat([path UTF16String], buffer); #else - return stat([path cStringWithEncoding: [OFString nativeOSEncoding]], - buffer); + return stat([path cStringWithEncoding: + [OFSystemInfo native8BitEncoding]], buffer); #endif } int of_lstat(OFString *path, of_stat_t *buffer) { #if defined(_WIN32) return _wstat([path UTF16String], buffer); #elif defined(HAVE_LSTAT) - return lstat([path cStringWithEncoding: [OFString nativeOSEncoding]], - buffer); + return lstat([path cStringWithEncoding: + [OFSystemInfo native8BitEncoding]], buffer); #else - return stat([path cStringWithEncoding: [OFString nativeOSEncoding]], - buffer); + return stat([path cStringWithEncoding: + [OFSystemInfo native8BitEncoding]], buffer); #endif } static int parseMode(const char *mode) @@ -235,12 +235,13 @@ wchar_t *buffer = _wgetcwd(NULL, 0); #endif @try { #ifndef _WIN32 - ret = [OFString stringWithCString: buffer - encoding: [OFString nativeOSEncoding]]; + ret = [OFString + stringWithCString: buffer + encoding: [OFSystemInfo native8BitEncoding]]; #else ret = [OFString stringWithUTF16String: buffer]; #endif } @finally { free(buffer); @@ -303,14 +304,14 @@ { if (path == nil) @throw [OFInvalidArgumentException exception]; #ifndef _WIN32 - if (mkdir([path cStringWithEncoding: [OFString nativeOSEncoding]], - DIR_MODE)) + if (mkdir([path cStringWithEncoding: [OFSystemInfo native8BitEncoding]], + DIR_MODE) != 0) #else - if (_wmkdir([path UTF16String])) + if (_wmkdir([path UTF16String]) != 0) #endif @throw [OFCreateDirectoryFailedException exceptionWithPath: path]; } @@ -370,11 +371,11 @@ files = [OFMutableArray array]; #ifndef _WIN32 DIR *dir; - encoding = [OFString nativeOSEncoding]; + encoding = [OFSystemInfo native8BitEncoding]; if ((dir = opendir([path cStringWithEncoding: encoding])) == NULL) @throw [OFOpenFileFailedException exceptionWithPath: path mode: @"r"]; @@ -465,13 +466,14 @@ { if (path == nil) @throw [OFInvalidArgumentException exception]; #ifndef _WIN32 - if (chdir([path cStringWithEncoding: [OFString nativeOSEncoding]])) + if (chdir([path cStringWithEncoding: + [OFSystemInfo native8BitEncoding]]) != 0) #else - if (_wchdir([path UTF16String])) + if (_wchdir([path UTF16String]) != 0) #endif @throw [OFChangeCurrentDirectoryPathFailedException exceptionWithPath: path]; } @@ -513,14 +515,14 @@ { if (path == nil) @throw [OFInvalidArgumentException exception]; # ifndef _WIN32 - if (chmod([path cStringWithEncoding: [OFString nativeOSEncoding]], - permissions)) + if (chmod([path cStringWithEncoding: [OFSystemInfo native8BitEncoding]], + permissions) != 0) # else - if (_wchmod([path UTF16String], permissions)) + if (_wchmod([path UTF16String], permissions) != 0) # endif @throw [OFChangePermissionsFailedException exceptionWithPath: path permissions: permissions]; } @@ -536,11 +538,11 @@ of_string_encoding_t encoding; if (path == nil || (owner == nil && group == nil)) @throw [OFInvalidArgumentException exception]; - encoding = [OFString nativeOSEncoding]; + encoding = [OFSystemInfo native8BitEncoding]; # ifdef OF_HAVE_THREADS if (!of_mutex_lock(&mutex)) @throw [OFLockFailedException exception]; @@ -576,11 +578,11 @@ if (!of_mutex_unlock(&mutex)) @throw [OFUnlockFailedException exception]; } # endif - if (chown([path cStringWithEncoding: encoding], uid, gid)) + if (chown([path cStringWithEncoding: encoding], uid, gid) != 0) @throw [OFChangeOwnerFailedException exceptionWithPath: path owner: owner group: group]; } #endif @@ -601,11 +603,11 @@ @throw [OFCopyItemFailedException exceptionWithSourcePath: source destinationPath: destination]; } - if (of_lstat(source, &s)) + if (of_lstat(source, &s) != 0) @throw [OFCopyItemFailedException exceptionWithSourcePath: source destinationPath: destination]; if (S_ISDIR(s.st_mode)) { @@ -722,16 +724,16 @@ exceptionWithSourcePath: source destinationPath: destination]; } #ifndef _WIN32 - encoding = [OFString nativeOSEncoding]; + encoding = [OFSystemInfo native8BitEncoding]; if (rename([source cStringWithEncoding: encoding], - [destination cStringWithEncoding: encoding])) { + [destination cStringWithEncoding: encoding]) != 0) { #else - if (_wrename([source UTF16String], [destination UTF16String])) { + if (_wrename([source UTF16String], [destination UTF16String]) != 0) { #endif if (errno != EXDEV) @throw [OFMoveItemFailedException exceptionWithSourcePath: source destinationPath: destination]; @@ -766,11 +768,11 @@ if (path == nil) @throw [OFInvalidArgumentException exception]; pool = objc_autoreleasePoolPush(); - if (of_lstat(path, &s)) + if (of_lstat(path, &s) != 0) @throw [OFRemoveItemFailedException exceptionWithPath: path]; if (S_ISDIR(s.st_mode)) { OFArray *contents; OFEnumerator *enumerator; @@ -793,13 +795,14 @@ objc_autoreleasePoolPop(pool2); } } #ifndef _WIN32 - if (remove([path cStringWithEncoding: [OFString nativeOSEncoding]])) + if (remove([path cStringWithEncoding: + [OFSystemInfo native8BitEncoding]]) != 0) #else - if (_wremove([path UTF16String])) + if (_wremove([path UTF16String]) != 0) #endif @throw [OFRemoveItemFailedException exceptionWithPath: path]; objc_autoreleasePoolPop(pool); } @@ -813,11 +816,11 @@ if (source == nil || destination == nil) @throw [OFInvalidArgumentException exception]; pool = objc_autoreleasePoolPush(); - encoding = [OFString nativeOSEncoding]; + encoding = [OFSystemInfo native8BitEncoding]; if (link([source cStringWithEncoding: encoding], [destination cStringWithEncoding: encoding]) != 0) @throw [OFLinkFailedException exceptionWithSourcePath: source @@ -836,11 +839,11 @@ if (source == nil || destination == nil) @throw [OFInvalidArgumentException exception]; pool = objc_autoreleasePoolPush(); - encoding = [OFString nativeOSEncoding]; + encoding = [OFSystemInfo native8BitEncoding]; if (symlink([source cStringWithEncoding: encoding], [destination cStringWithEncoding: encoding]) != 0) @throw [OFCreateSymbolicLinkFailedException exceptionWithSourcePath: source @@ -856,11 +859,11 @@ of_string_encoding_t encoding; if (path == nil) @throw [OFInvalidArgumentException exception]; - encoding = [OFString nativeOSEncoding]; + encoding = [OFSystemInfo native8BitEncoding]; length = readlink([path cStringWithEncoding: encoding], destination, PATH_MAX); if (length < 0) @throw [OFOpenFileFailedException exceptionWithPath: path @@ -887,12 +890,12 @@ if ((flags = parseMode([mode UTF8String])) == -1) @throw [OFInvalidArgumentException exception]; #ifndef _WIN32 - if ((_fd = open([path cStringWithEncoding: - [OFString nativeOSEncoding]], flags, DEFAULT_MODE)) == -1) + if ((_fd = open([path cStringWithEncoding: [OFSystemInfo + native8BitEncoding]], flags, DEFAULT_MODE)) == -1) #else if ((_fd = _wopen([path UTF16String], flags, DEFAULT_MODE)) == -1) #endif @throw [OFOpenFileFailedException