@@ -26,11 +26,13 @@ #endif #import "OFFile.h" #import "OFString.h" #import "OFArray.h" -#import "OFThread.h" +#ifdef OF_THREADS +# import "OFThread.h" +#endif #import "OFDate.h" #import "OFAutoreleasePool.h" #import "OFExceptions.h" #import "macros.h" @@ -60,11 +62,11 @@ OFFile *of_stdin = nil; OFFile *of_stdout = nil; OFFile *of_stderr = nil; -#ifndef _WIN32 +#if defined(OF_THREADS) && !defined(_WIN32) static OFMutex *mutex; #endif static int parse_mode(const char *mode) { @@ -108,11 +110,11 @@ of_stdin = [[OFFileSingleton alloc] initWithFileDescriptor: 0]; of_stdout = [[OFFileSingleton alloc] initWithFileDescriptor: 1]; of_stderr = [[OFFileSingleton alloc] initWithFileDescriptor: 2]; } -#ifndef _WIN32 +#if defined(OF_THREADS) && !defined(_WIN32) + (void)initialize { if (self == [OFFile class]) mutex = [[OFMutex alloc] init]; } @@ -418,13 +420,15 @@ if (owner == nil && group == nil) @throw [OFInvalidArgumentException newWithClass: self selector: _cmd]; +# ifdef OF_THREADS [mutex lock]; @try { +# endif if (owner != nil) { struct passwd *pw; if ((pw = getpwnam([owner cString])) == NULL) @throw [OFChangeFileOwnerFailedException @@ -446,13 +450,15 @@ owner: owner group: group]; gid = gr->gr_gid; } +# ifdef OF_THREADS } @finally { [mutex unlock]; } +# endif if (chown([path cString], uid, gid)) @throw [OFChangeFileOwnerFailedException newWithClass: self path: path owner: owner