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: 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