Overview
Comment: | Better method names for file- and stream-related exceptions. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
1f19713fd30a646dc9dbcefa717819b1 |
User & Date: | js on 2010-04-17 21:43:15 |
Other Links: | manifest | tags |
Context
2010-04-17
| ||
22:27 | New ivar naming convention. check-in: 37db8f0fb3 user: js tags: trunk | |
21:43 | Better method names for file- and stream-related exceptions. check-in: 1f19713fd3 user: js tags: trunk | |
18:54 | Move objfw-config --compile into a new script called objfw-compile. check-in: 53f21dd6a8 user: js tags: trunk | |
Changes
Modified src/OFExceptions.h from [ff60e9a5c7] to [f8a53f2bce].
︙ | ︙ | |||
498 499 500 501 502 503 504 | #endif /** * \brief An exception indicating that renaming a file failed. */ @interface OFRenameFileFailedException: OFException { | | | | | | | | | | | | | | | | 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 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 | #endif /** * \brief An exception indicating that renaming a file failed. */ @interface OFRenameFileFailedException: OFException { OFString *src; OFString *dst; int err; } /** * \param class_ The class of the object which caused the exception * \param src The original path * \param dst The new path * \return A new rename file failed exception */ + newWithClass: (Class)class_ sourcePath: (OFString*)src destinationPath: (OFString*)dst; /** * Initializes an already allocated rename failed exception. * * \param class_ The class of the object which caused the exception * \param src The original path * \param dst The new path * \return An initialized rename file failed exception */ - initWithClass: (Class)class_ sourcePath: (OFString*)src destinationPath: (OFString*)dst; /** * \return The errno from when the exception was created */ - (int)errNo; /** * \return The original path */ - (OFString*)sourcePath; /** * \return The new path */ - (OFString*)destinationPath; @end /** * \brief An exception indicating that deleting a file failed. */ @interface OFDeleteFileFailedException: OFException { |
︙ | ︙ | |||
596 597 598 599 600 601 602 | /** * \param class_ The class of the object which caused the exception * \param src The source for the link * \param dest The destination for the link * \return A new link failed exception */ | | | | | | | | | | | | | | | | | | 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 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 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 | /** * \param class_ The class of the object which caused the exception * \param src The source for the link * \param dest The destination for the link * \return A new link failed exception */ + newWithClass: (Class)class_ sourcePath: (OFString*)src destinationPath: (OFString*)dest; /** * Initializes an already allocated link failed exception. * * \param class_ The class of the object which caused the exception * \param src The source for the link * \param dest The destination for the link * \return An initialized link failed exception */ - initWithClass: (Class)class_ sourcePath: (OFString*)src destinationPath: (OFString*)dest; /** * \return The errno from when the exception was created */ - (int)errNo; /** * \return A string with the source for the link */ - (OFString*)sourcePath; /** * \return A string with the destination for the link */ - (OFString*)destinationPath; @end /** * \brief An exception indicating that creating a symlink failed. */ @interface OFSymlinkFailedException: OFException { OFString *src; OFString *dest; int err; } /** * \param class_ The class of the object which caused the exception * \param src The source for the symlink * \param dest The destination for the symlink * \return A new symlink failed exception */ + newWithClass: (Class)class_ sourcePath: (OFString*)src destinationPath: (OFString*)dest; /** * Initializes an already allocated symlink failed exception. * * \param class_ The class of the object which caused the exception * \param src The source for the symlink * \param dest The destination for the symlink * \return An initialized symlink failed exception */ - initWithClass: (Class)class_ sourcePath: (OFString*)src destinationPath: (OFString*)dest; /** * \return The errno from when the exception was created */ - (int)errNo; /** * \return A string with the source for the symlink */ - (OFString*)sourcePath; /** * \return A string with the destination for the symlink */ - (OFString*)destinationPath; @end #endif /** * \brief An exception indicating that setting an option failed. */ @interface OFSetOptionFailedException: OFException {} |
︙ | ︙ |
Modified src/OFExceptions.m from [8a8ab778d8] to [7ab9c8b826].
︙ | ︙ | |||
707 708 709 710 711 712 713 | { return group; } @end #endif @implementation OFRenameFileFailedException | | | | | | | | | | | | | | | | | | | | 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 | { return group; } @end #endif @implementation OFRenameFileFailedException + newWithClass: (Class)class__ sourcePath: (OFString*)src_ destinationPath: (OFString*)dst_ { return [[self alloc] initWithClass: class__ sourcePath: src_ destinationPath: dst_]; } - initWithClass: (Class)class__ { @throw [OFNotImplementedException newWithClass: isa selector: _cmd]; } - initWithClass: (Class)class__ sourcePath: (OFString*)src_ destinationPath: (OFString*)dst_ { self = [super initWithClass: class__]; src = [src_ copy]; dst = [dst_ copy]; err = GET_ERR; return self; } - (void)dealloc { [src release]; [dst release]; [super dealloc]; } - (OFString*)string { if (string != nil) return string; string = [[OFString alloc] initWithFormat: @"Failed to rename file %s to %s in class %s! " ERRFMT, [src cString], [dst cString], [class_ className], ERRPARAM]; return string; } - (int)errNo { return err; } - (OFString*)sourcePath { return src; } - (OFString*)destinationPath; { return dst; } @end @implementation OFDeleteFileFailedException + newWithClass: (Class)class__ path: (OFString*)path_ { |
︙ | ︙ | |||
828 829 830 831 832 833 834 | { return path; } @end #ifndef _WIN32 @implementation OFLinkFailedException | | | | | | | | | | 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 | { return path; } @end #ifndef _WIN32 @implementation OFLinkFailedException + newWithClass: (Class)class__ sourcePath: (OFString*)src_ destinationPath: (OFString*)dest_ { return [[self alloc] initWithClass: class__ sourcePath: src_ destinationPath: dest_]; } - initWithClass: (Class)class__ { @throw [OFNotImplementedException newWithClass: isa selector: _cmd]; } - initWithClass: (Class)class__ sourcePath: (OFString*)src_ destinationPath: (OFString*)dest_ { self = [super initWithClass: class__]; src = [src_ copy]; dest = [dest_ copy]; err = GET_ERR; |
︙ | ︙ | |||
881 882 883 884 885 886 887 | } - (int)errNo { return err; } | | | | | | | | | | | | 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 | } - (int)errNo { return err; } - (OFString*)sourcePath { return src; } - (OFString*)destinationPath { return dest; } @end @implementation OFSymlinkFailedException + newWithClass: (Class)class__ sourcePath: (OFString*)src_ destinationPath: (OFString*)dest_ { return [[self alloc] initWithClass: class__ sourcePath: src_ destinationPath: dest_]; } - initWithClass: (Class)class__ { @throw [OFNotImplementedException newWithClass: isa selector: _cmd]; } - initWithClass: (Class)class__ sourcePath: (OFString*)src_ destinationPath: (OFString*)dest_ { self = [super initWithClass: class__]; src = [src_ copy]; dest = [dest_ copy]; err = GET_ERR; |
︙ | ︙ | |||
946 947 948 949 950 951 952 | } - (int)errNo { return err; } | | | | 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 | } - (int)errNo { return err; } - (OFString*)sourcePath { return src; } - (OFString*)destinationPath { return dest; } @end #endif @implementation OFSetOptionFailedException |
︙ | ︙ |
Modified src/OFFile.m from [f9f8e25035] to [87ff6efbc7].
︙ | ︙ | |||
260 261 262 263 264 265 266 | { #ifndef _WIN32 if (rename([from cString], [to cString])) #else if (!MoveFile([from cString], [to cString])) #endif @throw [OFRenameFileFailedException newWithClass: self | | | | | | | | 260 261 262 263 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 299 300 301 302 303 304 305 | { #ifndef _WIN32 if (rename([from cString], [to cString])) #else if (!MoveFile([from cString], [to cString])) #endif @throw [OFRenameFileFailedException newWithClass: self sourcePath: from destinationPath: to]; } + (void)deleteFileAtPath: (OFString*)path { #ifndef _WIN32 if (unlink([path cString])) #else if (!DeleteFile([path cString])) #endif @throw [OFDeleteFileFailedException newWithClass: self path: path]; } #ifndef _WIN32 + (void)linkFileAtPath: (OFString*)src toPath: (OFString*)dest { if (link([src cString], [dest cString]) != 0) @throw [OFLinkFailedException newWithClass: self sourcePath: src destinationPath: dest]; } + (void)symlinkFileAtPath: (OFString*)src toPath: (OFString*)dest { if (symlink([src cString], [dest cString]) != 0) @throw [OFSymlinkFailedException newWithClass: self sourcePath: src destinationPath: dest]; } #endif - init { @throw [OFNotImplementedException newWithClass: isa selector: _cmd]; |
︙ | ︙ |