Overview
Comment: | Fix conversion between URL and path on Win32
This also adds -[OFURL fileSystemRepresentation] to correctly convert a |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
b83d1414b18615b3813d10d6647c251b |
User & Date: | js on 2017-10-29 00:41:52 |
Other Links: | manifest | tags |
Context
2017-10-29
| ||
01:41 | OFFileManager: Add URL versions of all methods check-in: dd467ddb20 user: js tags: trunk | |
00:41 | Fix conversion between URL and path on Win32 check-in: b83d1414b1 user: js tags: trunk | |
2017-10-28
| ||
23:52 | OFURL: Return a proper URL for +[fileURLWithPath:] check-in: 8aa7f964bc user: js tags: trunk | |
Changes
Modified src/OFData.m from [118e27647e] to [878145eec0].
︙ | ︙ | |||
240 241 242 243 244 245 246 | pool = objc_autoreleasePoolPush(); scheme = [URL scheme]; # ifdef OF_HAVE_FILES if ([scheme isEqual: @"file"]) | | > | 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 | pool = objc_autoreleasePoolPush(); scheme = [URL scheme]; # ifdef OF_HAVE_FILES if ([scheme isEqual: @"file"]) self = [self initWithContentsOfFile: [URL fileSystemRepresentation]]; else # endif @throw [OFUnsupportedProtocolException exceptionWithURL: URL]; objc_autoreleasePoolPop(pool); return self; |
︙ | ︙ |
Modified src/OFFileManager.m from [d45420d7bb] to [c6f7e83a5a].
︙ | ︙ | |||
297 298 299 300 301 302 303 304 305 306 307 308 309 310 | #if OF_PATH_DELIMITER != '/' path = [[[self currentDirectoryPath] pathComponents] componentsJoinedByString: @"/"]; #else path = [self currentDirectoryPath]; #endif [URL setPath: [path stringByAppendingString: @"/"]]; [URL makeImmutable]; objc_autoreleasePoolPop(pool); | > > > > | 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 | #if OF_PATH_DELIMITER != '/' path = [[[self currentDirectoryPath] pathComponents] componentsJoinedByString: @"/"]; #else path = [self currentDirectoryPath]; #endif #ifndef OF_PATH_STARTS_WITH_SLASH path = [path stringByPrependingString: @"/"]; #endif [URL setPath: [path stringByAppendingString: @"/"]]; [URL makeImmutable]; objc_autoreleasePoolPop(pool); |
︙ | ︙ |
Modified src/OFString.m from [66df8d1952] to [e0c9985c5f].
︙ | ︙ | |||
1037 1038 1039 1040 1041 1042 1043 | OFString *scheme = [URL scheme]; # ifdef OF_HAVE_FILES if ([scheme isEqual: @"file"]) { if (encoding == OF_STRING_ENCODING_AUTODETECT) encoding = OF_STRING_ENCODING_UTF_8; | | > | | 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 | OFString *scheme = [URL scheme]; # ifdef OF_HAVE_FILES if ([scheme isEqual: @"file"]) { if (encoding == OF_STRING_ENCODING_AUTODETECT) encoding = OF_STRING_ENCODING_UTF_8; self = [self initWithContentsOfFile: [URL fileSystemRepresentation] encoding: encoding]; } else # endif @throw [OFUnsupportedProtocolException exceptionWithURL: URL]; objc_autoreleasePoolPop(pool); return self; |
︙ | ︙ | |||
2203 2204 2205 2206 2207 2208 2209 | if (OF_IS_PATH_DELIMITER(characters[i])) { [ret addObject: [self substringWithRange: of_range(last, i - last)]]; last = i + 1; } } | < < < < < < < < < < < < | 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 | if (OF_IS_PATH_DELIMITER(characters[i])) { [ret addObject: [self substringWithRange: of_range(last, i - last)]]; last = i + 1; } } [ret addObject: [self substringWithRange: of_range(last, i - last)]]; [ret makeImmutable]; objc_autoreleasePoolPop(pool); return ret; } |
︙ | ︙ |
Modified src/OFString_UTF8.m from [9568261c3b] to [c30817026a].
︙ | ︙ | |||
1165 1166 1167 1168 1169 1170 1171 | if (OF_IS_PATH_DELIMITER(_s->cString[i])) { [ret addObject: [OFString stringWithUTF8String: _s->cString + last length: i - last]]; last = i + 1; } } | < < < < < < < < < < < < | 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 | if (OF_IS_PATH_DELIMITER(_s->cString[i])) { [ret addObject: [OFString stringWithUTF8String: _s->cString + last length: i - last]]; last = i + 1; } } [ret addObject: [OFString stringWithUTF8String: _s->cString + last length: i - last]]; [ret makeImmutable]; objc_autoreleasePoolPop(pool); return ret; } |
︙ | ︙ |
Modified src/OFURL.h from [b68aeab9b8] to [cd4f15175b].
︙ | ︙ | |||
133 134 135 136 137 138 139 140 141 142 143 144 | /*! * @brief Returns the URL as a string. * * @return The URL as a string */ - (OFString *)string; @end OF_ASSUME_NONNULL_END #import "OFMutableURL.h" | > > > > > > > > > > | 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | /*! * @brief Returns the URL as a string. * * @return The URL as a string */ - (OFString *)string; /*! * @brief Returns the local file system representation for a file URL. * * This only exists for URLs with the file scheme and throws an exception * otherwise. * * @return The local file system representation for a file URL */ - (nullable OFString *)fileSystemRepresentation; @end OF_ASSUME_NONNULL_END #import "OFMutableURL.h" |
Modified src/OFURL.m from [5a68687d28] to [7016e3a6f1].
︙ | ︙ | |||
478 479 480 481 482 483 484 485 486 487 488 489 490 491 | objc_autoreleasePoolPop(pool); [ret makeImmutable]; return ret; } - (OFString *)description { return [OFString stringWithFormat: @"<%@: %@>", [self class], [self string]]; } | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 | objc_autoreleasePoolPop(pool); [ret makeImmutable]; return ret; } - (OFString *)fileSystemRepresentation { void *pool = objc_autoreleasePoolPush(); OFString *path; if (![_scheme isEqual: @"file"]) @throw [OFInvalidArgumentException exception]; if (![_path hasPrefix: @"/"]) @throw [OFInvalidFormatException exception]; path = [[_path copy] autorelease]; if ([path hasSuffix: @"/"]) path = [path substringWithRange: of_range(0, [path length] - 1)]; #ifndef OF_PATH_STARTS_WITH_SLASH path = [path substringWithRange: of_range(1, [path length] - 1)]; #endif #if OF_PATH_DELIMITER != '/' path = [OFString pathWithComponents: [path componentsSeparatedByString: @"/"]]; #endif [path retain]; objc_autoreleasePoolPop(pool); return [path autorelease]; } - (OFString *)description { return [OFString stringWithFormat: @"<%@: %@>", [self class], [self string]]; } |
︙ | ︙ |
Modified src/macros.h from [298ad747ab] to [40aa2d8e24].
︙ | ︙ | |||
324 325 326 327 328 329 330 331 332 333 334 335 336 337 | #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 == '/') #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 @".." | > | 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 | #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 @".." |
︙ | ︙ |