@@ -33,12 +33,14 @@ #include #include #include #include -#ifndef _WIN32 +#ifdef HAVE_PWD_H # include +#endif +#ifdef HAVE_GRP_H # include #endif #import "OFFile.h" #import "OFString.h" @@ -99,11 +101,11 @@ OFStream *of_stdin = nil; OFStream *of_stdout = nil; OFStream *of_stderr = nil; -#if defined(OF_HAVE_THREADS) && !defined(_WIN32) +#if defined(OF_HAVE_CHOWN) && defined(OF_HAVE_THREADS) static of_mutex_t mutex; #endif static int parse_mode(const char *mode) { @@ -160,11 +162,11 @@ @interface OFFileSingleton: OFFile @end @implementation OFFile -#if defined(OF_HAVE_THREADS) && !defined(_WIN32) +#if defined(OF_HAVE_CHOWN) && defined(OF_HAVE_THREADS) + (void)initialize { if (self != [OFFile class]) return; @@ -387,11 +389,11 @@ @throw [OFChangeDirectoryFailedException exceptionWithClass: self path: path]; } -#ifndef _PSP +#ifdef OF_HAVE_CHMOD + (void)changeModeOfFileAtPath: (OFString*)path mode: (mode_t)mode { # ifndef _WIN32 if (chmod([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE], mode)) @@ -444,11 +446,11 @@ /* FIXME: We could be more precise on some OSes */ return [OFDate dateWithTimeIntervalSince1970: s.st_mtime]; } -#if !defined(_WIN32) && !defined(_PSP) +#ifdef OF_HAVE_CHOWN + (void)changeOwnerOfFileAtPath: (OFString*)path owner: (OFString*)owner group: (OFString*)group { uid_t uid = -1; @@ -545,11 +547,11 @@ length: pageSize]; [destinationFile writeBuffer: buffer length: length]; } -#if !defined(_WIN32) && !defined(_PSP) +#ifdef OF_HAVE_CHMOD if (!override) { struct stat s; if (fstat(sourceFile->_fd, &s) == 0) fchmod(destinationFile->_fd, s.st_mode); @@ -612,11 +614,11 @@ @throw [OFDeleteDirectoryFailedException exceptionWithClass: self path: path]; } -#ifndef _WIN32 +#ifdef OF_HAVE_LINK + (void)linkFileAtPath: (OFString*)source toPath: (OFString*)destination { void *pool = objc_autoreleasePoolPush(); @@ -634,11 +636,11 @@ objc_autoreleasePoolPop(pool); } #endif -#if !defined(_WIN32) && !defined(_PSP) +#ifdef OF_HAVE_SYMLINK + (void)symlinkFileAtPath: (OFString*)source toPath: (OFString*)destination { void *pool = objc_autoreleasePoolPush();