Overview
| Comment: | Don't use utimes() on AmigaOS
It's not available on MorphOS and the implementation in libnix for |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
137dc2107d5c07be5e7a192d56770788 |
| User & Date: | js on 2020-06-16 21:46:53 |
| Other Links: | manifest | tags |
Context
|
2020-06-20
| ||
| 13:56 | OFRunLoop: Make of_run_loop_mode_default const (check-in: d6709240fd user: js tags: trunk) | |
|
2020-06-16
| ||
| 21:46 | Don't use utimes() on AmigaOS (check-in: 137dc2107d user: js tags: trunk) | |
|
2020-06-14
| ||
| 19:00 | .travis.yml: Remove STDOUT_SIMPLE (check-in: 141b8181c0 user: js tags: trunk) | |
Changes
Modified src/OFFileURLHandler.m from [9591e49fd5] to [94bc38aa32].
| ︙ | ︙ | |||
14 15 16 17 18 19 20 21 22 23 24 25 26 27 | * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #include <errno.h> #ifdef HAVE_DIRENT_H # include <dirent.h> #endif #include "unistd_wrapper.h" #import "platform.h" | > | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #include <errno.h> #include <math.h> #ifdef HAVE_DIRENT_H # include <dirent.h> #endif #include "unistd_wrapper.h" #import "platform.h" |
| ︙ | ︙ | |||
147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
errno = EBUSY;
return;
}
errno = 0;
}
#endif
static int
of_stat(OFString *path, of_stat_t *buffer)
{
#if defined(OF_WINDOWS)
WIN32_FILE_ATTRIBUTE_DATA data;
bool success;
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
errno = EBUSY;
return;
}
errno = 0;
}
#endif
#ifdef OF_AMIGAOS
static void
setErrno(void)
{
switch (IoErr()) {
case ERROR_DELETE_PROTECTED:
case ERROR_READ_PROTECTED:
case ERROR_WRITE_PROTECTED:
errno = EACCES;
break;
case ERROR_DISK_NOT_VALIDATED:
case ERROR_OBJECT_IN_USE:
errno = EBUSY;
break;
case ERROR_OBJECT_EXISTS:
errno = EEXIST;
break;
case ERROR_DIR_NOT_FOUND:
case ERROR_NO_MORE_ENTRIES:
case ERROR_OBJECT_NOT_FOUND:
errno = ENOENT;
break;
case ERROR_NO_FREE_STORE:
errno = ENOMEM;
break;
case ERROR_DISK_FULL:
errno = ENOSPC;
break;
case ERROR_DIRECTORY_NOT_EMPTY:
errno = ENOTEMPTY;
break;
case ERROR_DISK_WRITE_PROTECTED:
errno = EROFS;
break;
case ERROR_RENAME_ACROSS_DEVICES:
errno = EXDEV;
break;
default:
errno = 0;
break;
}
}
#endif
static int
of_stat(OFString *path, of_stat_t *buffer)
{
#if defined(OF_WINDOWS)
WIN32_FILE_ATTRIBUTE_DATA data;
bool success;
|
| ︙ | ︙ | |||
227 228 229 230 231 232 233 |
# endif
of_time_interval_t timeInterval;
struct Locale *locale;
struct DateStamp *date;
if ((lock = Lock([path cStringWithEncoding: [OFLocale encoding]],
SHARED_LOCK)) == 0) {
| < < < < < < < < < | < < < | 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 |
# endif
of_time_interval_t timeInterval;
struct Locale *locale;
struct DateStamp *date;
if ((lock = Lock([path cStringWithEncoding: [OFLocale encoding]],
SHARED_LOCK)) == 0) {
setErrno();
return -1;
}
# ifdef OF_AMIGAOS4
if ((ed = ExamineObjectTags(EX_FileLockInput, lock, TAG_END)) == NULL) {
# else
if (!Examine(lock, &fib)) {
|
| ︙ | ︙ | |||
619 620 621 622 623 624 625 | : of_file_attribute_key_last_access_date); if (lastAccessDate == nil) lastAccessDate = modificationDate; if (modificationDate == nil) modificationDate = lastAccessDate; | | | 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 |
: of_file_attribute_key_last_access_date);
if (lastAccessDate == nil)
lastAccessDate = modificationDate;
if (modificationDate == nil)
modificationDate = lastAccessDate;
#if defined(OF_WINDOWS)
if (func__wutime64 != NULL) {
struct __utimbuf64 times = {
.actime =
(__time64_t)lastAccessDate.timeIntervalSince1970,
.modtime =
(__time64_t)modificationDate.timeIntervalSince1970
};
|
| ︙ | ︙ | |||
655 656 657 658 659 660 661 662 663 664 665 666 667 668 |
if (status != 0)
@throw [OFSetItemAttributesFailedException
exceptionWithURL: URL
attributes: attributes
failedAttribute: attributeKey
errNo: errno];
}
#else
of_time_interval_t lastAccessTime =
lastAccessDate.timeIntervalSince1970;
of_time_interval_t modificationTime =
modificationDate.timeIntervalSince1970;
struct timeval times[2] = {
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 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 |
if (status != 0)
@throw [OFSetItemAttributesFailedException
exceptionWithURL: URL
attributes: attributes
failedAttribute: attributeKey
errNo: errno];
}
#elif defined(OF_AMIGAOS)
/* AmigaOS does not support access time. */
of_time_interval_t modificationTime =
modificationDate.timeIntervalSince1970;
struct Locale *locale;
struct DateStamp date;
modificationTime -= 252460800; /* 1978-01-01 */
if (modificationTime < 0)
@throw [OFOutOfRangeException exception];
locale = OpenLocale(NULL);
/*
* FIXME: This does not take DST into account. But unfortunately, there
* is no way to figure out if DST should be in effect for the
* timestamp.
*/
modificationTime -= locale->loc_GMTOffset * 60.0;
CloseLocale(locale);
date.ds_Days = modificationTime / 86400;
date.ds_Minute = ((LONG)modificationTime % 86400) / 60;
date.ds_Tick = fmod(modificationTime, 60) * TICKS_PER_SECOND;
if (!SetFileDate([path cStringWithEncoding: [OFLocale encoding]],
&date) != 0) {
setErrno();
@throw [OFSetItemAttributesFailedException
exceptionWithURL: URL
attributes: attributes
failedAttribute: attributeKey
errNo: errno];
}
#else
of_time_interval_t lastAccessTime =
lastAccessDate.timeIntervalSince1970;
of_time_interval_t modificationTime =
modificationDate.timeIntervalSince1970;
struct timeval times[2] = {
|
| ︙ | ︙ | |||
915 916 917 918 919 920 921 |
exceptionWithURL: URL
errNo: errno];
#elif defined(OF_AMIGAOS)
BPTR lock;
if ((lock = CreateDir(
[path cStringWithEncoding: [OFLocale encoding]])) == 0) {
| < | < < < < < < < < < < < < < < < < < < < < < | < | | 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 |
exceptionWithURL: URL
errNo: errno];
#elif defined(OF_AMIGAOS)
BPTR lock;
if ((lock = CreateDir(
[path cStringWithEncoding: [OFLocale encoding]])) == 0) {
setErrno();
@throw [OFCreateDirectoryFailedException
exceptionWithURL: URL
errNo: errno];
}
UnLock(lock);
#else
if (mkdir([path cStringWithEncoding: [OFLocale encoding]], 0777) != 0)
@throw [OFCreateDirectoryFailedException
exceptionWithURL: URL
|
| ︙ | ︙ | |||
1067 1068 1069 1070 1071 1072 1073 |
}
#elif defined(OF_AMIGAOS)
of_string_encoding_t encoding = [OFLocale encoding];
BPTR lock;
if ((lock = Lock([path cStringWithEncoding: encoding],
SHARED_LOCK)) == 0) {
| < | < < < < < < < < < < < < | | 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 |
}
#elif defined(OF_AMIGAOS)
of_string_encoding_t encoding = [OFLocale encoding];
BPTR lock;
if ((lock = Lock([path cStringWithEncoding: encoding],
SHARED_LOCK)) == 0) {
setErrno();
@throw [OFOpenItemFailedException exceptionWithURL: URL
mode: nil
errNo: errno];
}
@try {
# ifdef OF_AMIGAOS4
struct ExamineData *ed;
APTR context;
|
| ︙ | ︙ | |||
1303 1304 1305 1306 1307 1308 1309 |
exceptionWithURL: URL
errNo: errno];
#endif
}
#ifdef OF_AMIGAOS
if (!DeleteFile([path cStringWithEncoding: [OFLocale encoding]])) {
| < | < < < < < < < < < < < < < < < < < | < | | 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 |
exceptionWithURL: URL
errNo: errno];
#endif
}
#ifdef OF_AMIGAOS
if (!DeleteFile([path cStringWithEncoding: [OFLocale encoding]])) {
setErrno();
@throw [OFRemoveItemFailedException exceptionWithURL: URL
errNo: errno];
}
#endif
objc_autoreleasePoolPop(pool);
}
#ifdef OF_FILE_MANAGER_SUPPORTS_LINKS
|
| ︙ | ︙ | |||
1439 1440 1441 1442 1443 1444 1445 |
#ifdef OF_AMIGAOS
of_string_encoding_t encoding = [OFLocale encoding];
if (!Rename([source.fileSystemRepresentation
cStringWithEncoding: encoding],
[destination.fileSystemRepresentation
cStringWithEncoding: encoding])) {
| < | < < < < < < < < < < < < < < < < < < < < < | | 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 |
#ifdef OF_AMIGAOS
of_string_encoding_t encoding = [OFLocale encoding];
if (!Rename([source.fileSystemRepresentation
cStringWithEncoding: encoding],
[destination.fileSystemRepresentation
cStringWithEncoding: encoding])) {
setErrno();
@throw [OFMoveItemFailedException
exceptionWithSourceURL: source
destinationURL: destination
errNo: errno];
}
#else
int status;
# ifdef OF_WINDOWS
if ([OFSystemInfo isWindowsNT])
status = _wrename(source.fileSystemRepresentation.UTF16String,
|
| ︙ | ︙ |