Index: generators/TableGenerator.m ================================================================== --- generators/TableGenerator.m +++ generators/TableGenerator.m @@ -269,21 +269,19 @@ } while (!done); } - (void)writeFiles { - OFString *path; + OFURL *URL; [of_stdout writeString: @"Writing files…"]; - path = [OFString pathWithComponents: [OFArray arrayWithObjects: - OF_PATH_PARENT_DIRECTORY, @"src", @"unicode.m", nil]]; - [self writeTablesToFile: path]; + URL = [OFURL fileURLWithPath: @"../src/unicode.m"]; + [self writeTablesToFile: [URL fileSystemRepresentation]]; - path = [OFString pathWithComponents: [OFArray arrayWithObjects: - OF_PATH_PARENT_DIRECTORY, @"src", @"unicode.h", nil]]; - [self writeHeaderToFile: path]; + URL = [OFURL fileURLWithPath: @"../src/unicode.h"]; + [self writeHeaderToFile: [URL fileSystemRepresentation]]; [of_stdout writeLine: @" done"]; [OFApplication terminate]; } Index: src/OFString+PathAdditions_UNIX.m ================================================================== --- src/OFString+PathAdditions_UNIX.m +++ src/OFString+PathAdditions_UNIX.m @@ -167,11 +167,11 @@ } } objc_autoreleasePoolPop(pool); - return OF_PATH_CURRENT_DIRECTORY; + return @"."; } - (OFString *)stringByDeletingPathExtension { void *pool; Index: src/OFURL.m ================================================================== --- src/OFURL.m +++ src/OFURL.m @@ -603,12 +603,18 @@ bool isDirectory; @try { void *pool = objc_autoreleasePoolPush(); - isDirectory = ([path hasSuffix: OF_PATH_DELIMITER_STRING] || +#if defined(OF_WINDOWS) || defined(OF_MSDOS) + isDirectory = ([path hasSuffix: @"\\"] || + [path hasSuffix: @"/"] || + [OFURLHandler_file of_directoryExistsAtPath: path]); +#else + isDirectory = ([path hasSuffix: @"/"] || [OFURLHandler_file of_directoryExistsAtPath: path]); +#endif objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e; @@ -625,38 +631,32 @@ { self = [super init]; @try { void *pool = objc_autoreleasePoolPush(); -# if OF_PATH_DELIMITER != '/' || defined(OF_WINDOWS) || defined(OF_DJGPP) +# if defined(OF_WINDOWS) || defined(OF_DJGPP) OFArray OF_GENERIC(OFString *) *pathComponents = [path pathComponents]; -# endif -# if OF_PATH_DELIMITER != '/' path = [pathComponents componentsJoinedByString: @"/"]; -# endif -# if defined(OF_WINDOWS) || defined(OF_DJGPP) if ([[pathComponents firstObject] hasSuffix: @":"]) path = [path stringByPrependingString: @"/"]; # endif - if (isDirectory && ![path hasSuffix: OF_PATH_DELIMITER_STRING]) + if (isDirectory && ![path hasSuffix: @"/"]) path = [path stringByAppendingString: @"/"]; _URLEncodedScheme = @"file"; if (![path hasPrefix: @"/"]) { OFString *currentDirectoryPath = [[OFFileManager defaultManager] currentDirectoryPath]; -# if OF_PATH_DELIMITER != '/' +# if defined(OF_WINDOWS) || defined(OF_DJGPP) currentDirectoryPath = [[currentDirectoryPath pathComponents] componentsJoinedByString: @"/"]; -# endif -# if defined(OF_WINDOWS) || defined(OF_DJGPP) currentDirectoryPath = [currentDirectoryPath stringByPrependingString: @"/"]; # endif path = [currentDirectoryPath @@ -973,15 +973,12 @@ if ([path hasSuffix: @"/"]) path = [path substringWithRange: of_range(0, [path length] - 1)]; -#ifndef OF_PATH_STARTS_WITH_SLASH +#if defined(OF_WINDOWS) || defined(OF_MSDOS) path = [path substringWithRange: of_range(1, [path length] - 1)]; -#endif - -#if OF_PATH_DELIMITER != '/' path = [OFString pathWithComponents: [path componentsSeparatedByString: @"/"]]; #endif [path retain]; Index: src/macros.h ================================================================== --- src/macros.h +++ src/macros.h @@ -354,23 +354,10 @@ #endif #define OF_RETAIN_COUNT_MAX UINT_MAX #define OF_NOT_FOUND SIZE_MAX -#if !defined(OF_WINDOWS) && !defined(OF_MSDOS) -# define OF_PATH_DELIMITER '/' -# define OF_PATH_DELIMITER_STRING @"/" -# define OF_IS_PATH_DELIMITER(c) (c == '/') -# define OF_PATH_STARTS_WITH_SLASH -#else -# define OF_PATH_DELIMITER '\\' -# define OF_PATH_DELIMITER_STRING @"\\" -# define OF_IS_PATH_DELIMITER(c) (c == '\\' || c == '/') -#endif -#define OF_PATH_CURRENT_DIRECTORY @"." -#define OF_PATH_PARENT_DIRECTORY @".." - #define OF_ENSURE(cond) \ do { \ if (!(cond)) { \ fprintf(stderr, "Failed to ensure condition " \ "in " __FILE__ ":%d:\n" #cond "\n", \ Index: tests/OFStringTests.m ================================================================== --- tests/OFStringTests.m +++ tests/OFStringTests.m @@ -551,14 +551,22 @@ TEST(@"-[stringByPrependingString:]", [[C(@"foo") stringByPrependingString: @"bar"] isEqual: @"barfoo"]) #ifdef OF_HAVE_FILES s[0] = [mutableStringClass stringWithString: @"foo"]; - [s[0] appendString: OF_PATH_DELIMITER_STRING]; +# if defined(OF_WINDOWS) || defined(OF_MSDOS) + [s[0] appendString: @"\\"]; +# else + [s[0] appendString: @"/"]; +# endif [s[0] appendString: @"bar"]; s[1] = [mutableStringClass stringWithString: s[0]]; - [s[1] appendString: OF_PATH_DELIMITER_STRING]; +# if defined(OF_WINDOWS) || defined(OF_MSDOS) + [s[1] appendString: @"\\"]; +# else + [s[1] appendString: @"/"]; +# endif is = [stringClass stringWithString: s[1]]; [s[1] appendString: @"baz"]; TEST(@"-[stringByAppendingPathComponent:]", [[s[0] stringByAppendingPathComponent: @"baz"] isEqual: s[1]] && [[is stringByAppendingPathComponent: @"baz"] isEqual: s[1]]) Index: utils/ofzip/TarArchive.m ================================================================== --- utils/ofzip/TarArchive.m +++ utils/ofzip/TarArchive.m @@ -294,11 +294,12 @@ goto outer_loop_end; } pathComponents = [outFileName pathComponents]; for (OFString *component in pathComponents) { - if ([component isEqual: OF_PATH_PARENT_DIRECTORY]) { + if ([component length] == 0 || + [component isEqual: @".."]) { [of_stderr writeLine: OF_LOCALIZED( @"refusing_to_extract_file", @"Refusing to extract %[file]!", @"file", fileName)]; Index: utils/ofzip/ZIPArchive.m ================================================================== --- utils/ofzip/ZIPArchive.m +++ utils/ofzip/ZIPArchive.m @@ -235,11 +235,12 @@ goto outer_loop_end; } pathComponents = [outFileName pathComponents]; for (OFString *component in pathComponents) { - if ([component isEqual: OF_PATH_PARENT_DIRECTORY]) { + if ([component length] == 0 || + [component isEqual: @".."]) { [of_stderr writeLine: OF_LOCALIZED( @"refusing_to_extract_file", @"Refusing to extract %[file]!", @"file", fileName)];