Overview
Comment: | Add -[OFString stringByAppendingPathExtension:] |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
c258e7bfad182bd25ac704e8ba739dc9 |
User & Date: | js on 2022-08-07 13:31:28 |
Other Links: | manifest | tags |
Context
2022-08-07
| ||
13:32 | utils: Properly uninstall objfw-embed check-in: 057802f120 user: js tags: trunk | |
13:31 | Add -[OFString stringByAppendingPathExtension:] check-in: c258e7bfad user: js tags: trunk | |
2022-08-06
| ||
21:38 | OFTCPSocket: Fix missing cast check-in: 26f1bac7a1 user: js tags: trunk | |
Changes
Modified src/OFString+PathAdditions.h from [c69c663e20] to [2a2be8d086].
︙ | ︙ | |||
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | * @brief Creates a new string by appending a path component. * * @param component The path component to append * @return A new, autoreleased OFString with the path component appended */ - (OFString *)stringByAppendingPathComponent: (OFString *)component; - (bool)of_isDirectoryPath; - (OFString *)of_pathToURLPathWithURLEncodedHost: (OFString *__autoreleasing _Nullable *_Nonnull)URLEncodedHost; - (OFString *)of_URLPathToPathWithURLEncodedHost: (nullable OFString *)URLEncodedHost; - (OFString *)of_pathComponentToURLPathComponent; @end OF_ASSUME_NONNULL_END | > > > > > > > > | 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | * @brief Creates a new string by appending a path component. * * @param component The path component to append * @return A new, autoreleased OFString with the path component appended */ - (OFString *)stringByAppendingPathComponent: (OFString *)component; /** * @brief Creates a new string by appending a path extension. * * @param extension The extension to append * @return A new, autoreleased OFString with the path extension appended */ - (OFString *)stringByAppendingPathExtension: (OFString *)extension; - (bool)of_isDirectoryPath; - (OFString *)of_pathToURLPathWithURLEncodedHost: (OFString *__autoreleasing _Nullable *_Nonnull)URLEncodedHost; - (OFString *)of_URLPathToPathWithURLEncodedHost: (nullable OFString *)URLEncodedHost; - (OFString *)of_pathComponentToURLPathComponent; @end OF_ASSUME_NONNULL_END |
Modified src/platform/AmigaOS/OFString+PathAdditions.m from [8907c31289] to [1da7b3fb62].
︙ | ︙ | |||
264 265 266 267 268 269 270 271 272 273 274 275 276 277 | [ret appendString: component]; [ret makeImmutable]; return ret; } } - (bool)of_isDirectoryPath { return ([self hasSuffix: @"/"] || [self hasSuffix: @":"] || [OFFileURLHandler of_directoryExistsAtPath: self]); } | > > > > > > > > > > > > > > > > > > > > > | 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 | [ret appendString: component]; [ret makeImmutable]; return ret; } } - (OFString *)stringByAppendingPathExtension: (OFString *)extension { if ([self hasSuffix: @"/"]) { void *pool = objc_autoreleasePoolPush(); OFMutableArray *components; OFString *fileName, *ret; components = [[self.pathComponents mutableCopy] autorelease]; fileName = [components.lastObject stringByAppendingFormat: @".%@", extension]; [components replaceObjectAtIndex: components.count - 1 withObject: fileName]; ret = [[OFString pathWithComponents: components] retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } else return [self stringByAppendingFormat: @".%@", extension]; } - (bool)of_isDirectoryPath { return ([self hasSuffix: @"/"] || [self hasSuffix: @":"] || [OFFileURLHandler of_directoryExistsAtPath: self]); } |
︙ | ︙ |
Modified src/platform/POSIX/OFString+PathAdditions.m from [33c84f0ae4] to [fcc8205b0e].
︙ | ︙ | |||
309 310 311 312 313 314 315 316 317 318 319 320 321 322 | [ret appendString: component]; [ret makeImmutable]; return ret; } } - (bool)of_isDirectoryPath { return ([self hasSuffix: @"/"] || [OFFileURLHandler of_directoryExistsAtPath: self]); } | > > > > > > > > > > > > > > > > > > > > > | 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 | [ret appendString: component]; [ret makeImmutable]; return ret; } } - (OFString *)stringByAppendingPathExtension: (OFString *)extension { if ([self hasSuffix: @"/"]) { void *pool = objc_autoreleasePoolPush(); OFMutableArray *components; OFString *fileName, *ret; components = [[self.pathComponents mutableCopy] autorelease]; fileName = [components.lastObject stringByAppendingFormat: @".%@", extension]; [components replaceObjectAtIndex: components.count - 1 withObject: fileName]; ret = [[OFString pathWithComponents: components] retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } else return [self stringByAppendingFormat: @".%@", extension]; } - (bool)of_isDirectoryPath { return ([self hasSuffix: @"/"] || [OFFileURLHandler of_directoryExistsAtPath: self]); } |
︙ | ︙ |
Modified src/platform/Windows/OFString+PathAdditions.m from [3d18ffcbdd] to [353eef09b4].
︙ | ︙ | |||
314 315 316 317 318 319 320 321 322 323 324 325 326 327 | [ret appendString: component]; [ret makeImmutable]; return ret; } } - (bool)of_isDirectoryPath { return ([self hasSuffix: @"\\"] || [self hasSuffix: @"/"] || [OFFileURLHandler of_directoryExistsAtPath: self]); } | > > > > > > > > > > > > > > > > > > > > > | 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 | [ret appendString: component]; [ret makeImmutable]; return ret; } } - (OFString *)stringByAppendingPathExtension: (OFString *)extension { if ([self hasSuffix: @"\\"] || [self hasSuffix: @"/"]) { void *pool = objc_autoreleasePoolPush(); OFMutableArray *components; OFString *fileName, *ret; components = [[self.pathComponents mutableCopy] autorelease]; fileName = [components.lastObject stringByAppendingFormat: @".%@", extension]; [components replaceObjectAtIndex: components.count - 1 withObject: fileName]; ret = [[OFString pathWithComponents: components] retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } else return [self stringByAppendingFormat: @".%@", extension]; } - (bool)of_isDirectoryPath { return ([self hasSuffix: @"\\"] || [self hasSuffix: @"/"] || [OFFileURLHandler of_directoryExistsAtPath: self]); } |
︙ | ︙ |
Modified src/platform/libfat/OFString+PathAdditions.m from [9b9e52f706] to [7996727ec2].
︙ | ︙ | |||
310 311 312 313 314 315 316 317 318 319 320 321 322 323 | [ret appendString: component]; [ret makeImmutable]; return ret; } } - (bool)of_isDirectoryPath { return ([self hasSuffix: @"/"] || [OFFileURLHandler of_directoryExistsAtPath: self]); } | > > > > > > > > > > > > > > > > > > > > > | 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 | [ret appendString: component]; [ret makeImmutable]; return ret; } } - (OFString *)stringByAppendingPathExtension: (OFString *)extension { if ([self hasSuffix: @"/"]) { void *pool = objc_autoreleasePoolPush(); OFMutableArray *components; OFString *fileName, *ret; components = [[self.pathComponents mutableCopy] autorelease]; fileName = [components.lastObject stringByAppendingFormat: @".%@", extension]; [components replaceObjectAtIndex: components.count - 1 withObject: fileName]; ret = [[OFString pathWithComponents: components] retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } else return [self stringByAppendingFormat: @".%@", extension]; } - (bool)of_isDirectoryPath { return ([self hasSuffix: @"/"] || [OFFileURLHandler of_directoryExistsAtPath: self]); } |
︙ | ︙ |
Modified tests/OFStringTests.m from [9b77bee5fe] to [bed905834b].
︙ | ︙ | |||
591 592 593 594 595 596 597 598 599 600 601 602 603 604 | string = [stringClass stringWithString: mutableString2]; [mutableString2 appendString: @"baz"]; TEST(@"-[stringByAppendingPathComponent:]", [[mutableString1 stringByAppendingPathComponent: @"baz"] isEqual: mutableString2] && [[string stringByAppendingPathComponent: @"baz"] isEqual: mutableString2]) #endif TEST(@"-[hasPrefix:]", [C(@"foobar") hasPrefix: @"foo"] && ![C(@"foobar") hasPrefix: @"foobar0"]) TEST(@"-[hasSuffix:]", [C(@"foobar") hasSuffix: @"bar"] && ![C(@"foobar") hasSuffix: @"foobar0"]) | > > > > > > > > > > > > > > > > > > | 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 | string = [stringClass stringWithString: mutableString2]; [mutableString2 appendString: @"baz"]; TEST(@"-[stringByAppendingPathComponent:]", [[mutableString1 stringByAppendingPathComponent: @"baz"] isEqual: mutableString2] && [[string stringByAppendingPathComponent: @"baz"] isEqual: mutableString2]) # if defined(OF_WINDOWS) || defined(OF_MSDOS) TEST(@"-[stringByAppendingPathExtension:]", [[C(@"foo") stringByAppendingPathExtension: @"bar"] isEqual: @"foo.bar"] && [[C(@"c:\\tmp\\foo") stringByAppendingPathExtension: @"bar"] isEqual: @"c:\\tmp\\foo.bar"] && [[C(@"c:\\tmp\\/\\") stringByAppendingPathExtension: @"bar"] isEqual: @"c:\\tmp.bar"]) # else TEST(@"-[stringByAppendingPathExtension:]", [[C(@"foo") stringByAppendingPathExtension: @"bar"] isEqual: @"foo.bar"] && [[C(@"foo/bar") stringByAppendingPathExtension: @"baz"] isEqual: @"foo/bar.baz"] && [[C(@"foo///") stringByAppendingPathExtension: @"bar"] isEqual: @"foo.bar"]) # endif #endif TEST(@"-[hasPrefix:]", [C(@"foobar") hasPrefix: @"foo"] && ![C(@"foobar") hasPrefix: @"foobar0"]) TEST(@"-[hasSuffix:]", [C(@"foobar") hasSuffix: @"bar"] && ![C(@"foobar") hasSuffix: @"foobar0"]) |
︙ | ︙ |