Overview
Comment: | OFFileManager: More use of native APIs on MorphOS
This uses native AmigaDOS APIs for directory-related operations. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
f119b9dc07f36384a7a18a83f03d3b96 |
User & Date: | js on 2017-06-10 21:08:14 |
Other Links: | manifest | tags |
Context
2017-06-10
| ||
22:20 | OFFileManager: More use of native APIs on MorphOS check-in: 749855ed2b user: js tags: trunk | |
21:08 | OFFileManager: More use of native APIs on MorphOS check-in: f119b9dc07 user: js tags: trunk | |
11:46 | macros.h: Add of_ascii_isspace() check-in: dbdc125802 user: js tags: trunk | |
Changes
Modified src/OFFileManager.m from [36a1dbfadd] to [1dffeceb89].
︙ | ︙ | |||
56 57 58 59 60 61 62 63 64 65 66 67 68 69 | #import "OFInvalidArgumentException.h" #import "OFLinkFailedException.h" #import "OFLockFailedException.h" #import "OFMoveItemFailedException.h" #import "OFNotImplementedException.h" #import "OFOpenItemFailedException.h" #import "OFOutOfMemoryException.h" #import "OFReadFailedException.h" #import "OFRemoveItemFailedException.h" #import "OFStatItemFailedException.h" #import "OFUnlockFailedException.h" #ifdef OF_WINDOWS # include <windows.h> | > | 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | #import "OFInvalidArgumentException.h" #import "OFLinkFailedException.h" #import "OFLockFailedException.h" #import "OFMoveItemFailedException.h" #import "OFNotImplementedException.h" #import "OFOpenItemFailedException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFRemoveItemFailedException.h" #import "OFStatItemFailedException.h" #import "OFUnlockFailedException.h" #ifdef OF_WINDOWS # include <windows.h> |
︙ | ︙ | |||
100 101 102 103 104 105 106 107 108 109 110 111 112 113 | #if !defined(HAVE_READDIR_R) && defined(OF_HAVE_THREADS) && !defined(OF_WINDOWS) static OFMutex *readdirMutex; #endif #ifdef OF_WINDOWS static WINAPI BOOLEAN (*func_CreateSymbolicLinkW)(LPCWSTR, LPCWSTR, DWORD); #endif static int of_stat(OFString *path, of_stat_t *buffer) { #if defined(OF_WINDOWS) return _wstat64([path UTF16String], buffer); #elif defined(OF_MORPHOS) | > > > > > > > > > > > | 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | #if !defined(HAVE_READDIR_R) && defined(OF_HAVE_THREADS) && !defined(OF_WINDOWS) static OFMutex *readdirMutex; #endif #ifdef OF_WINDOWS static WINAPI BOOLEAN (*func_CreateSymbolicLinkW)(LPCWSTR, LPCWSTR, DWORD); #endif #ifdef OF_MORPHOS static bool dirChanged = false; static BPTR originalDirLock = 0; OF_DESTRUCTOR() { if (dirChanged) UnLock(CurrentDir(originalDirLock)); } #endif static int of_stat(OFString *path, of_stat_t *buffer) { #if defined(OF_WINDOWS) return _wstat64([path UTF16String], buffer); #elif defined(OF_MORPHOS) |
︙ | ︙ | |||
226 227 228 229 230 231 232 233 | + (OFFileManager *)defaultManager { return defaultManager; } - (OFString *)currentDirectoryPath { OFString *ret; | > < < < < < | > > > > > > > > > > > > > > > > | | > > > > | > | > | 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 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 | + (OFFileManager *)defaultManager { return defaultManager; } - (OFString *)currentDirectoryPath { #if defined(OF_WINDOWS) OFString *ret; wchar_t *buffer = _wgetcwd(NULL, 0); @try { ret = [OFString stringWithUTF16String: buffer]; } @finally { free(buffer); } return ret; #elif defined(OF_MORPHOS) char buffer[512]; if (!NameFromLock(((struct Process *)FindTask(NULL))->pr_CurrentDir, buffer, 512)) { if (IoErr() == ERROR_LINE_TOO_LONG) @throw [OFOutOfRangeException exception]; return nil; } return [OFString stringWithCString: buffer encoding: [OFLocalization encoding]]; #else OFString *ret; char *buffer = getcwd(NULL, 0); @try { ret = [OFString stringWithCString: buffer encoding: [OFLocalization encoding]]; } @finally { free(buffer); } return ret; #endif } - (bool)fileExistsAtPath: (OFString *)path { of_stat_t s; if (path == nil) |
︙ | ︙ | |||
307 308 309 310 311 312 313 | #endif - (void)createDirectoryAtPath: (OFString *)path { if (path == nil) @throw [OFInvalidArgumentException exception]; | | > > > > > > > > | > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | < > | 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 | #endif - (void)createDirectoryAtPath: (OFString *)path { if (path == nil) @throw [OFInvalidArgumentException exception]; #if defined(OF_WINDOWS) if (_wmkdir([path UTF16String]) != 0) @throw [OFCreateDirectoryFailedException exceptionWithPath: path errNo: errno]; #elif defined(OF_MORPHOS) BPTR lock; if ((lock = CreateDir( [path cStringWithEncoding: [OFLocalization encoding]])) == 0) { int errNo; switch (IoErr()) { case ERROR_NO_FREE_STORE: case ERROR_DISK_FULL: errNo = ENOSPC; break; case ERROR_OBJECT_IN_USE: case ERROR_DISK_NOT_VALIDATED: errNo = EBUSY; break; case ERROR_OBJECT_EXISTS: errNo = EEXIST; break; case ERROR_OBJECT_NOT_FOUND: errNo = ENOENT; break; case ERROR_DISK_WRITE_PROTECTED: errNo = EROFS; break; default: errNo = 0; break; } @throw [OFCreateDirectoryFailedException exceptionWithPath: path errNo: errNo]; } UnLock(lock); #else if (mkdir([path cStringWithEncoding: [OFLocalization encoding]], 0777) != 0) @throw [OFCreateDirectoryFailedException exceptionWithPath: path errNo: errno]; #endif } - (void)createDirectoryAtPath: (OFString *)path createParents: (bool)createParents { OFString *currentPath = nil; |
︙ | ︙ | |||
480 481 482 483 484 485 486 | } - (void)changeCurrentDirectoryPath: (OFString *)path { if (path == nil) @throw [OFInvalidArgumentException exception]; | | > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > | > | > | > > | 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 | } - (void)changeCurrentDirectoryPath: (OFString *)path { if (path == nil) @throw [OFInvalidArgumentException exception]; #if defined(OF_WINDOWS) if (_wchdir([path UTF16String]) != 0) @throw [OFChangeCurrentDirectoryPathFailedException exceptionWithPath: path errNo: errno]; #elif defined(OF_MORPHOS) BPTR lock, oldLock; if ((lock = Lock([path cStringWithEncoding: [OFLocalization encoding]], SHARED_LOCK)) == 0) { int errNo; switch (IoErr()) { case ERROR_OBJECT_IN_USE: case ERROR_DISK_NOT_VALIDATED: errNo = EBUSY; break; case ERROR_OBJECT_NOT_FOUND: errNo = ENOENT; break; default: errNo = 0; break; } @throw [OFChangeCurrentDirectoryPathFailedException exceptionWithPath: path errNo: errNo]; } oldLock = CurrentDir(lock); if (!dirChanged) originalDirLock = oldLock; else UnLock(oldLock); dirChanged = true; #else if (chdir([path cStringWithEncoding: [OFLocalization encoding]]) != 0) @throw [OFChangeCurrentDirectoryPathFailedException exceptionWithPath: path errNo: errno]; #endif } - (of_offset_t)sizeOfFileAtPath: (OFString *)path { of_stat_t s; if (path == nil) |
︙ | ︙ |