Index: src/OFFile.m ================================================================== --- src/OFFile.m +++ src/OFFile.m @@ -39,10 +39,16 @@ # define S_IRGRP 0 #endif #ifndef S_IROTH # define S_IROTH 0 #endif +#ifndef S_IWGRP +# define S_IWGRP 0 +#endif +#ifndef S_IWOTH +# define S_IWOTH 0 +#endif #define DEFAULT_MODE S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH #define DIR_MODE DEFAULT_MODE | S_IXUSR | S_IXGRP | S_IXOTH OFFile *of_stdin = nil; @@ -114,15 +120,23 @@ ssize_t i; if (path_len == 0) return @""; +#ifndef _WIN32 if (path_c[path_len - 1] == OF_PATH_DELIM) +#else + if (path_c[path_len - 1] == '/' || path_c[path_len - 1] == '\\') +#endif path_len--; for (i = path_len - 1; i >= 0; i--) { +#ifndef _WIN32 if (path_c[i] == OF_PATH_DELIM) { +#else + if (path_c[i] == '/' || path_c[i] == '\\') { +#endif i++; break; } } @@ -316,16 +330,18 @@ intoBuffer: buf]; [dest writeNBytes: len fromBuffer: buf]; } +#ifndef _WIN32 if (!override) { struct stat s; if (fstat(src->fd, &s) == 0) fchmod(dest->fd, s.st_mode); } +#endif } @finally { [src close]; [dest close]; } Index: src/OFObject.h ================================================================== --- src/OFObject.h +++ src/OFObject.h @@ -138,12 +138,12 @@ * * \param selector The selector of the class method to replace * \param class_ The class from which the new class method should be taken * \return The old implementation */ -+ (IMP)replaceClassMethod: (SEL)selector - withClassMethodFromClass: (Class)class_; ++ (IMP)replaceClassMethod: (SEL)selector + withMethodFromClass: (Class)class_; /** * Replaces an instance method implementation with another implementation. * * \param newimp The new implementation for the instance method @@ -158,12 +158,12 @@ * * \param selector The selector of the instance method to replace * \param class_ The class from which the new instance method should be taken * \return The old implementation */ -+ (IMP)replaceInstanceMethod: (SEL)selector - withInstanceMethodFromClass: (Class)class_; ++ (IMP)replaceInstanceMethod: (SEL)selector + withMethodFromClass: (Class)class_; /** * Initializes an already allocated object. * * Derived classes may override this, but need to do self = [super init] before Index: src/OFObject.m ================================================================== --- src/OFObject.m +++ src/OFObject.m @@ -260,14 +260,18 @@ return oldimp; #endif } -+ (IMP)replaceClassMethod: (SEL)selector - withClassMethodFromClass: (Class)class; ++ (IMP)replaceClassMethod: (SEL)selector + withMethodFromClass: (Class)class; { IMP newimp; + + if (![class isSubclassOfClass: self]) + @throw [OFInvalidArgumentException newWithClass: self + selector: _cmd]; #if defined(OF_OBJFW_RUNTIME) newimp = objc_get_class_method(class, selector); #elif defined(OF_APPLE_RUNTIME) newimp = method_getImplementation(class_getClassMethod(class, @@ -312,14 +316,18 @@ return oldimp; #endif } -+ (IMP)replaceInstanceMethod: (SEL)selector - withInstanceMethodFromClass: (Class)class; ++ (IMP)replaceInstanceMethod: (SEL)selector + withMethodFromClass: (Class)class; { IMP newimp; + + if (![class isSubclassOfClass: self]) + @throw [OFInvalidArgumentException newWithClass: self + selector: _cmd]; #if defined(OF_OBJFW_RUNTIME) newimp = objc_get_instance_method(class, selector); #elif defined(OF_APPLE_RUNTIME) newimp = class_getMethodImplementation(class, selector); Index: tests/OFFileTests.m ================================================================== --- tests/OFFileTests.m +++ tests/OFFileTests.m @@ -27,12 +27,12 @@ TEST(@"+[lastComponentOfPath", [[OFFile lastComponentOfPath: @"/tmp"] isEqual: @"tmp"] && [[OFFile lastComponentOfPath: @"/tmp/"] isEqual: @"tmp"] && [[OFFile lastComponentOfPath: @"/"] isEqual: @""] && - [[OFFile lastComponentOfPath: @"foo"] isEqual: @"foo"] /* && + [[OFFile lastComponentOfPath: @"foo"] isEqual: @"foo"] && [[OFFile lastComponentOfPath: @"foo/bar"] isEqual: @"bar"] && - [[OFFile lastComponentOfPath: @"foo/bar/baz/"] isEqual: @"baz"]*/) + [[OFFile lastComponentOfPath: @"foo/bar/baz/"] isEqual: @"baz"]) [pool drain]; } @end