Overview
Comment: | +[stringWithPath:] -> +[pathWithComponents:].
This removes -[initWithPath:,...], so that it's finally possible to use |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
7c4179ab9b6d6c956fe921b0b79ccb46 |
User & Date: | js on 2013-08-14 19:17:10 |
Other Links: | manifest | tags |
Context
2013-08-14
| ||
19:28 | Rename -[initWith*Path:] to -[initWithPath:]. check-in: 0abd116830 user: js tags: trunk | |
19:17 | +[stringWithPath:] -> +[pathWithComponents:]. check-in: 7c4179ab9b user: js tags: trunk | |
13:18 | OFZIPArchive: Make meta data of files available. check-in: 2168071f36 user: js tags: trunk | |
Changes
Modified src/OFFile.m from [f060fd2dab] to [e0f0d0594a].
︙ | ︙ | |||
276 277 278 279 280 281 282 | pathComponents = [path pathComponents]; enumerator = [pathComponents objectEnumerator]; while ((component = [enumerator nextObject]) != nil) { void *pool2 = objc_autoreleasePoolPush(); if (currentPath != nil) | | | | 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 | pathComponents = [path pathComponents]; enumerator = [pathComponents objectEnumerator]; while ((component = [enumerator nextObject]) != nil) { void *pool2 = objc_autoreleasePoolPush(); if (currentPath != nil) currentPath = [currentPath stringByAppendingPathComponent: component]; else currentPath = component; if ([currentPath length] > 0 && ![OFFile directoryExistsAtPath: currentPath]) [OFFile createDirectoryAtPath: currentPath]; |
︙ | ︙ | |||
521 522 523 524 525 526 527 | if (source == nil || destination == nil) @throw [OFInvalidArgumentException exception]; pool = objc_autoreleasePoolPush(); if ([self directoryExistsAtPath: destination]) { | > | | < | 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 | if (source == nil || destination == nil) @throw [OFInvalidArgumentException exception]; pool = objc_autoreleasePoolPush(); if ([self directoryExistsAtPath: destination]) { OFArray *components = [OFArray arrayWithObjects: destination, [source lastPathComponent], nil]; destination = [OFString pathWithComponents: components]; } override = [self fileExistsAtPath: destination]; pageSize = [OFSystemInfo pageSize]; if ((buffer = malloc(pageSize)) == NULL) @throw [OFOutOfMemoryException |
︙ | ︙ | |||
579 580 581 582 583 584 585 | if (source == nil || destination == nil) @throw [OFInvalidArgumentException exception]; pool = objc_autoreleasePoolPush(); if ([self directoryExistsAtPath: destination]) { | > | | < | 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 | if (source == nil || destination == nil) @throw [OFInvalidArgumentException exception]; pool = objc_autoreleasePoolPush(); if ([self directoryExistsAtPath: destination]) { OFArray *components = [OFArray arrayWithObjects: destination, [source lastPathComponent], nil]; destination = [OFString pathWithComponents: components]; } #ifndef _WIN32 if (rename([source cStringWithEncoding: OF_STRING_ENCODING_NATIVE], [destination cStringWithEncoding: OF_STRING_ENCODING_NATIVE])) #else if (_wrename([source UTF16String], [destination UTF16String])) |
︙ | ︙ | |||
623 624 625 626 627 628 629 | if (source == nil || destination == nil) @throw [OFInvalidArgumentException exception]; pool = objc_autoreleasePoolPush(); if ([self directoryExistsAtPath: destination]) { | > | | < | 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 | if (source == nil || destination == nil) @throw [OFInvalidArgumentException exception]; pool = objc_autoreleasePoolPush(); if ([self directoryExistsAtPath: destination]) { OFArray *components = [OFArray arrayWithObjects: destination, [source lastPathComponent], nil]; destination = [OFString pathWithComponents: components]; } if (link([source cStringWithEncoding: OF_STRING_ENCODING_NATIVE], [destination cStringWithEncoding: OF_STRING_ENCODING_NATIVE]) != 0) @throw [OFLinkFailedException exceptionWithSourcePath: source destinationPath: destination]; |
︙ | ︙ | |||
650 651 652 653 654 655 656 | if (source == nil || destination == nil) @throw [OFInvalidArgumentException exception]; pool = objc_autoreleasePoolPush(); if ([self directoryExistsAtPath: destination]) { | > | | < | 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 | if (source == nil || destination == nil) @throw [OFInvalidArgumentException exception]; pool = objc_autoreleasePoolPush(); if ([self directoryExistsAtPath: destination]) { OFArray *components = [OFArray arrayWithObjects: destination, [source lastPathComponent], nil]; destination = [OFString pathWithComponents: components]; } if (symlink([source cStringWithEncoding: OF_STRING_ENCODING_NATIVE], [destination cStringWithEncoding: OF_STRING_ENCODING_NATIVE]) != 0) @throw [OFCreateSymbolicLinkFailedException exceptionWithSourcePath: source destinationPath: destination]; |
︙ | ︙ |
Modified src/OFMutableString.m from [8d0822912d] to [ad91789f29].
︙ | ︙ | |||
167 168 169 170 171 172 173 | - initWithFormat: (OFConstantString*)format arguments: (va_list)arguments { return (id)[[OFMutableString_UTF8 alloc] initWithFormat: format arguments: arguments]; } | < < < < < < < < < < < < < < < < < < < < | 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | - initWithFormat: (OFConstantString*)format arguments: (va_list)arguments { return (id)[[OFMutableString_UTF8 alloc] initWithFormat: format arguments: arguments]; } - initWithContentsOfFile: (OFString*)path { return (id)[[OFMutableString_UTF8 alloc] initWithContentsOfFile: path]; } - initWithContentsOfFile: (OFString*)path encoding: (of_string_encoding_t)encoding |
︙ | ︙ |
Modified src/OFString.h from [5f3de292e6] to [f3d3ca44b0].
︙ | ︙ | |||
268 269 270 271 272 273 274 | * specifier for objects. * * @param format A string used as format to initialize the OFString * @return A new autoreleased OFString */ + (instancetype)stringWithFormat: (OFConstantString*)format, ...; | < < < < < < < < | 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | * specifier for objects. * * @param format A string used as format to initialize the OFString * @return A new autoreleased OFString */ + (instancetype)stringWithFormat: (OFConstantString*)format, ...; /*! * @brief Creates a new OFString with the contents of the specified UTF-8 * encoded file. * * @param path The path to the file * @return A new autoreleased OFString */ |
︙ | ︙ | |||
321 322 323 324 325 326 327 328 329 330 331 332 333 334 | * @param URL The URL to the contents for the string * @param encoding The encoding to assume * @return A new autoreleased OFString */ + (instancetype)stringWithContentsOfURL: (OFURL*)URL encoding: (of_string_encoding_t)encoding; /*! * @brief Initializes an already allocated OFString from a UTF-8 encoded C * string. * * @param UTF8String A UTF-8 encoded C string to initialize the OFString with * @return An initialized OFString */ | > > > > > > > > | 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 | * @param URL The URL to the contents for the string * @param encoding The encoding to assume * @return A new autoreleased OFString */ + (instancetype)stringWithContentsOfURL: (OFURL*)URL encoding: (of_string_encoding_t)encoding; /*! * @brief Creates a path from the specified path components. * * @param components An array of components for the path * @return A new autoreleased OFString */ + (instancetype)pathWithComponents: (OFArray*)components; /*! * @brief Initializes an already allocated OFString from a UTF-8 encoded C * string. * * @param UTF8String A UTF-8 encoded C string to initialize the OFString with * @return An initialized OFString */ |
︙ | ︙ | |||
510 511 512 513 514 515 516 | * @param format A string used as format to initialize the OFString * @param arguments The arguments used in the format string * @return An initialized OFString */ - initWithFormat: (OFConstantString*)format arguments: (va_list)arguments; | < < < < < < < < < < < < < < < < < < < < | 510 511 512 513 514 515 516 517 518 519 520 521 522 523 | * @param format A string used as format to initialize the OFString * @param arguments The arguments used in the format string * @return An initialized OFString */ - initWithFormat: (OFConstantString*)format arguments: (va_list)arguments; /*! * @brief Initializes an already allocated OFString with the contents of the * specified file in the specified encoding. * * @param path The path to the file * @return An initialized OFString */ |
︙ | ︙ |
Modified src/OFString.m from [db848cd405] to [6989417794].
︙ | ︙ | |||
406 407 408 409 410 411 412 | - initWithFormat: (OFConstantString*)format arguments: (va_list)arguments { return (id)[[OFString_UTF8 alloc] initWithFormat: format arguments: arguments]; } | < < < < < < < < < < < < < < < < < < < < | 406 407 408 409 410 411 412 413 414 415 416 417 418 419 | - initWithFormat: (OFConstantString*)format arguments: (va_list)arguments { return (id)[[OFString_UTF8 alloc] initWithFormat: format arguments: arguments]; } - initWithContentsOfFile: (OFString*)path { return (id)[[OFString_UTF8 alloc] initWithContentsOfFile: path]; } - initWithContentsOfFile: (OFString*)path encoding: (of_string_encoding_t)encoding |
︙ | ︙ | |||
617 618 619 620 621 622 623 | ret = [[[self alloc] initWithFormat: format arguments: arguments] autorelease]; va_end(arguments); return ret; } | < < < < < < < < < < < < < | 597 598 599 600 601 602 603 604 605 606 607 608 609 610 | ret = [[[self alloc] initWithFormat: format arguments: arguments] autorelease]; va_end(arguments); return ret; } + (instancetype)stringWithContentsOfFile: (OFString*)path { return [[[self alloc] initWithContentsOfFile: path] autorelease]; } + (instancetype)stringWithContentsOfFile: (OFString*)path encoding: (of_string_encoding_t)encoding |
︙ | ︙ | |||
653 654 655 656 657 658 659 660 661 662 663 664 665 666 | + (instancetype)stringWithContentsOfURL: (OFURL*)URL encoding: (of_string_encoding_t)encoding { return [[[self alloc] initWithContentsOfURL: URL encoding: encoding] autorelease]; } - init { if (object_getClass(self) == [OFString class]) { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { | > > > > > > > > > > > > > > > > > > > | 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 | + (instancetype)stringWithContentsOfURL: (OFURL*)URL encoding: (of_string_encoding_t)encoding { return [[[self alloc] initWithContentsOfURL: URL encoding: encoding] autorelease]; } + (instancetype)pathWithComponents: (OFArray*)components { OFMutableString *ret = [OFMutableString string]; void *pool = objc_autoreleasePoolPush(); OFEnumerator *enumerator = [components objectEnumerator]; OFString *component; if ((component = [enumerator nextObject]) != nil) [ret appendString: component]; while ((component = [enumerator nextObject]) != nil) { [ret appendString: OF_PATH_DELIMITER_STRING]; [ret appendString: component]; } objc_autoreleasePoolPop(pool); return ret; } - init { if (object_getClass(self) == [OFString class]) { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { |
︙ | ︙ | |||
828 829 830 831 832 833 834 | return ret; } - initWithFormat: (OFConstantString*)format arguments: (va_list)arguments { | < < < < < < < < < < < < < < < < < < < < < < < < < < | 814 815 816 817 818 819 820 821 822 823 824 825 826 827 | return ret; } - initWithFormat: (OFConstantString*)format arguments: (va_list)arguments { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @throw e; } |
︙ | ︙ | |||
1805 1806 1807 1808 1809 1810 1811 | [new makeImmutable]; return new; } - (OFString*)stringByAppendingPathComponent: (OFString*)component { | > > > > | > > > > | 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 | [new makeImmutable]; return new; } - (OFString*)stringByAppendingPathComponent: (OFString*)component { void *pool = objc_autoreleasePoolPush(); OFString *ret; ret = [OFString pathWithComponents: [OFArray arrayWithObjects: self, component, nil]]; [ret retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } - (OFString*)stringByPrependingString: (OFString*)string { OFMutableString *new = [[string mutableCopy] autorelease]; [new appendString: self]; |
︙ | ︙ |
Modified src/OFString_UTF8.m from [9860c5f0d1] to [dcb1103ce6].
︙ | ︙ | |||
651 652 653 654 655 656 657 | free(tmp); } } @catch (id e) { [self release]; @throw e; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 651 652 653 654 655 656 657 658 659 660 661 662 663 664 | free(tmp); } } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { if (_s != NULL && _s->freeWhenDone != NULL) free(_s->freeWhenDone); |
︙ | ︙ |
Modified tests/OFStringTests.m from [fbc369ef09] to [a5ba78df50].
︙ | ︙ | |||
278 279 280 281 282 283 284 | componentsSeparatedByString: @"XX" options: OF_STRING_SKIP_EMPTY]) && [a count] == 3 && [[a objectAtIndex: i++] isEqual: @"foo"] && [[a objectAtIndex: i++] isEqual: @"bar"] && [[a objectAtIndex: i++] isEqual: @"baz"]) | | > | | > | 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 | componentsSeparatedByString: @"XX" options: OF_STRING_SKIP_EMPTY]) && [a count] == 3 && [[a objectAtIndex: i++] isEqual: @"foo"] && [[a objectAtIndex: i++] isEqual: @"bar"] && [[a objectAtIndex: i++] isEqual: @"baz"]) TEST(@"+[pathWithComponents:]", (is = [OFString pathWithComponents: [OFArray arrayWithObjects: @"foo", @"bar", @"baz", nil]]) && #ifndef _WIN32 [is isEqual: @"foo/bar/baz"] && #else [is isEqual: @"foo\\bar\\baz"] && #endif (is = [OFString pathWithComponents: [OFArray arrayWithObjects: @"foo", nil]]) && [is isEqual: @"foo"]) TEST(@"-[pathComponents]", /* /tmp */ (a = [@"/tmp" pathComponents]) && [a count] == 2 && [[a objectAtIndex: 0] isEqual: @""] && [[a objectAtIndex: 1] isEqual: @"tmp"] && |
︙ | ︙ |