Overview
Comment: | Add +[OFSystemInfo native8BitEncoding]
This replaces +[OFString nativeOSEncoding]. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
ec66e49dcaf27789f1f153e600223e7e |
User & Date: | js on 2014-10-04 21:59:51 |
Other Links: | manifest | tags |
Context
2014-10-24
| ||
19:12 | OFApplication: Use EXIT_SUCCESS as default status check-in: 46cf9f33a8 user: js tags: trunk | |
2014-10-04
| ||
21:59 | Add +[OFSystemInfo native8BitEncoding] check-in: ec66e49dca user: js tags: trunk | |
19:24 | threading: WinAPI's CriticalSection is recursive check-in: be99da0c09 user: js tags: trunk | |
Changes
Modified src/OFApplication.m from [96a35a73db] to [3fb6075d12].
︙ | |||
22 23 24 25 26 27 28 29 30 31 32 33 34 35 | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | + | #include <signal.h> #import "OFApplication.h" #import "OFString.h" #import "OFArray.h" #import "OFDictionary.h" #import "OFSystemInfo.h" #import "OFRunLoop.h" #import "OFRunLoop+Private.h" #import "OFThread.h" #import "OFThread+Private.h" #if defined(__MACH__) && !defined(OF_IOS) # include <crt_externs.h> |
︙ | |||
230 231 232 233 234 235 236 | 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 | - + | FreeEnvironmentStringsW(env0); #elif !defined(OF_IOS) if (env != NULL) { for (; *env != NULL; env++) { OFString *key, *value; char *sep; const of_string_encoding_t encoding = |
︙ | |||
332 333 334 335 336 337 338 | 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 | - + | OFMutableArray *arguments; int i; of_string_encoding_t encoding; _argc = argc; _argv = argv; |
︙ |
Modified src/OFFile.m from [10bc91c172] to [aaab12c640].
︙ | |||
122 123 124 125 126 127 128 | 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | - - + + - - + + - - + + | int of_stat(OFString *path, of_stat_t *buffer) { #ifdef _WIN32 return _wstat([path UTF16String], buffer); #else |
︙ | |||
233 234 235 236 237 238 239 | 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 | - - + + + | char *buffer = getcwd(NULL, 0); #else wchar_t *buffer = _wgetcwd(NULL, 0); #endif @try { #ifndef _WIN32 |
︙ | |||
301 302 303 304 305 306 307 | 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | - - + + - + | + (void)createDirectoryAtPath: (OFString*)path { if (path == nil) @throw [OFInvalidArgumentException exception]; #ifndef _WIN32 |
︙ | |||
368 369 370 371 372 373 374 | 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 | - + | @throw [OFInvalidArgumentException exception]; files = [OFMutableArray array]; #ifndef _WIN32 DIR *dir; |
︙ | |||
463 464 465 466 467 468 469 | 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 | - + + - + | + (void)changeCurrentDirectoryPath: (OFString*)path { if (path == nil) @throw [OFInvalidArgumentException exception]; #ifndef _WIN32 |
︙ | |||
511 512 513 514 515 516 517 | 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 | - - + + - + - + | + (void)changePermissionsOfItemAtPath: (OFString*)path permissions: (mode_t)permissions { if (path == nil) @throw [OFInvalidArgumentException exception]; # ifndef _WIN32 |
︙ | |||
574 575 576 577 578 579 580 | 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 | - + | # ifdef OF_HAVE_THREADS } @finally { if (!of_mutex_unlock(&mutex)) @throw [OFUnlockFailedException exception]; } # endif |
︙ | |||
599 600 601 602 603 604 605 | 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 | - + | if (of_lstat(destination, &s) == 0) { errno = EEXIST; @throw [OFCopyItemFailedException exceptionWithSourcePath: source destinationPath: destination]; } |
︙ | |||
720 721 722 723 724 725 726 | 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 | - + - + - + | errno = EEXIST; @throw [OFCopyItemFailedException exceptionWithSourcePath: source destinationPath: destination]; } #ifndef _WIN32 |
︙ | |||
764 765 766 767 768 769 770 | 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 | - + | of_stat_t s; if (path == nil) @throw [OFInvalidArgumentException exception]; pool = objc_autoreleasePoolPush(); |
︙ | |||
791 792 793 794 795 796 797 | 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 | - + + - + - + | [path stringByAppendingPathComponent: item]]; objc_autoreleasePoolPop(pool2); } } #ifndef _WIN32 |
︙ | |||
834 835 836 837 838 839 840 | 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 | - + - + | void *pool; of_string_encoding_t encoding; if (source == nil || destination == nil) @throw [OFInvalidArgumentException exception]; pool = objc_autoreleasePoolPush(); |
︙ | |||
885 886 887 888 889 890 891 | 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 | - - + + | @try { int flags; if ((flags = parseMode([mode UTF8String])) == -1) @throw [OFInvalidArgumentException exception]; #ifndef _WIN32 |
︙ |
Modified src/OFObject.m from [d6054ff862] to [da02b5a0e1].
︙ | |||
22 23 24 25 26 27 28 29 30 31 32 33 34 35 | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | + | #include <assert.h> #include <sys/time.h> #import "OFObject.h" #import "OFArray.h" #import "OFSystemInfo.h" #import "OFTimer.h" #import "OFRunLoop.h" #import "OFThread.h" #import "OFAllocFailedException.h" #import "OFEnumerationMutationException.h" #import "OFInitializationFailedException.h" |
︙ | |||
95 96 97 98 99 100 101 102 103 | 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | + - + - + | #if !defined(OF_APPLE_RUNTIME) || defined(__OBJC2__) static void uncaughtExceptionHandler(id exception) { OFString *description = [exception description]; OFArray *backtrace = nil; of_string_encoding_t encoding = [OFSystemInfo native8BitEncoding]; fprintf(stderr, "\nRuntime error: Unhandled exception:\n%s\n", |
︙ | |||
198 199 200 201 202 203 204 | 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | - + | return instance; } const char* _NSPrintForDebugger(id object) { return [[object description] |
︙ |
Modified src/OFPlugin.m from [72b6e8f4e8] to [0a0de2607d].
︙ | |||
21 22 23 24 25 26 27 28 29 30 31 32 33 34 | 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | + | #ifdef HAVE_DLFCN_H # include <dlfcn.h> #endif #import "OFPlugin.h" #import "OFString.h" #import "OFSystemInfo.h" #import "OFInitializationFailedException.h" #ifdef _WIN32 # define dlsym(handle, symbol) GetProcAddress(handle, symbol) # define dlclose(handle) FreeLibrary(handle) #endif |
︙ | |||
43 44 45 46 47 48 49 | 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | - + | init_plugin_t initPlugin; OFPlugin *plugin; path = [path stringByAppendingString: @PLUGIN_SUFFIX]; #ifndef _WIN32 if ((handle = dlopen([path cStringWithEncoding: |
︙ |
Modified src/OFProcess.m from [486d495193] to [940798f49a].
︙ | |||
34 35 36 37 38 39 40 41 42 43 44 45 46 47 | 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | + | #endif #import "OFProcess.h" #import "OFString.h" #import "OFArray.h" #import "OFDictionary.h" #import "OFDataArray.h" #import "OFSystemInfo.h" #import "OFInitializationFailedException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFWriteFailedException.h" #ifdef _WIN32 |
︙ | |||
144 145 146 147 148 149 150 | 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | - + | size_t i, count = [arguments count]; char **argv; of_string_encoding_t encoding; argv = [self allocMemoryWithSize: sizeof(char*) count: count + 2]; |
︙ | |||
309 310 311 312 313 314 315 | 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 | - + | char **envp; size_t i, count; of_string_encoding_t encoding; if (environment == nil) return NULL; |
︙ |
Modified src/OFString.h from [096e5cd183] to [77d2e6f919].
︙ | |||
322 323 324 325 326 327 328 | 322 323 324 325 326 327 328 329 330 331 332 333 334 335 | - - - - - - - - - - | * @brief Creates a path from the specified path components. * * @param components An array of components for the path * @return A new autoreleased OFString */ + (OFString*)pathWithComponents: (OFArray*)components; |
︙ |
Modified src/OFString.m from [1c567dbe1d] to [f631bc6b9b].
︙ | |||
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | + + - | #include <sys/stat.h> #import "OFString.h" #import "OFString_UTF8.h" #import "OFString_UTF8+Private.h" #import "OFArray.h" #import "OFDictionary.h" #import "OFDataArray.h" #import "OFSystemInfo.h" #ifdef OF_HAVE_FILES # import "OFFile.h" #endif #import "OFURL.h" #ifdef OF_HAVE_SOCKETS # import "OFHTTPClient.h" # import "OFHTTPRequest.h" # import "OFHTTPResponse.h" #endif |
︙ | |||
663 664 665 666 667 668 669 | 664 665 666 667 668 669 670 671 672 673 674 675 676 677 | - - - - - - | } objc_autoreleasePoolPop(pool); return ret; } |
︙ | |||
830 831 832 833 834 835 836 | 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 | - - + + | @try { OFFile *file; /* Make sure the file system is initialized */ [OFFile class]; |
︙ | |||
1156 1157 1158 1159 1160 1161 1162 | 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 | - + - | [self OF_getCString: cString maxLength: length + 1 encoding: encoding lossy: lossy]; break; default: |
︙ | |||
1214 1215 1216 1217 1218 1219 1220 | 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 | - + - | case OF_STRING_ENCODING_ASCII: case OF_STRING_ENCODING_ISO_8859_1: case OF_STRING_ENCODING_ISO_8859_15: case OF_STRING_ENCODING_WINDOWS_1252: case OF_STRING_ENCODING_CODEPAGE_437: return [self length]; default: |
︙ |
Modified src/OFSystemInfo.h from [3933be5d4b] to [feb5546006].
︙ | |||
11 12 13 14 15 16 17 | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | - - + | * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFObject.h" |
︙ | |||
36 37 38 39 40 41 42 43 44 45 46 47 48 49 | 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | + + + + + + + + + + | * * A CPU with multiple cores counts as multiple CPUs. * * @return The number of CPUs installed in the system */ + (size_t)numberOfCPUs; /*! * @brief Returns the native 8-bit string encoding of the operating system. * * This is useful to encode strings correctly for passing them to operating * system calls. * * @return The native 8-bit string encoding of the operating system */ + (of_string_encoding_t)native8BitEncoding; /*! * @brief Returns the path where user data for the application can be stored. * * On Unix systems, this adheres to the XDG Base Directory specification.@n * On Mac OS X and iOS, it uses the `NSApplicationSupportDirectory` directory.@n * On Windows, it uses the `APPDATA` environment variable.@n * On Haiku, it uses the `B_USER_SETTINGS_DIRECTORY` directory. |
︙ |
Modified src/OFSystemInfo.m from [2cb1c686e3] to [ff395665e2].
︙ | |||
87 88 89 90 91 92 93 94 95 96 97 98 99 100 | 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | + + + + + + | return pageSize; } + (size_t)numberOfCPUs { return numberOfCPUs; } + (of_string_encoding_t)native8BitEncoding { /* FIXME */ return OF_STRING_ENCODING_UTF_8; } + (OFString*)userDataPath { #if defined(__APPLE__) void *pool = objc_autoreleasePoolPush(); char pathC[PATH_MAX]; NSSearchPathEnumerationState state; |
︙ |