︙ | | |
35
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
|
-
+
|
# include <grp.h>
#endif
#import "OFURLHandler_file.h"
#import "OFArray.h"
#import "OFDate.h"
#import "OFFile.h"
#import "OFLocalization.h"
#import "OFLocale.h"
#import "OFNumber.h"
#import "OFURL.h"
#ifdef OF_HAVE_THREADS
# import "OFMutex.h"
#endif
|
︙ | | |
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
-
+
|
return _wstat64([path UTF16String], buffer);
#elif defined(OF_AMIGAOS)
BPTR lock;
struct FileInfoBlock fib;
of_time_interval_t timeInterval;
struct Locale *locale;
if ((lock = Lock([path cStringWithEncoding: [OFLocalization encoding]],
if ((lock = Lock([path cStringWithEncoding: [OFLocale encoding]],
SHARED_LOCK)) == 0) {
switch (IoErr()) {
case ERROR_OBJECT_IN_USE:
case ERROR_DISK_NOT_VALIDATED:
errno = EBUSY;
break;
case ERROR_OBJECT_NOT_FOUND:
|
︙ | | |
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
|
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
|
-
+
-
-
+
-
-
+
-
-
+
-
|
timeInterval +=
fib.fib_Date.ds_Tick / (of_time_interval_t)TICKS_PER_SECOND;
buffer->st_atime = buffer->st_mtime = buffer->st_ctime = timeInterval;
return 0;
#elif defined(OF_HAVE_OFF64_T)
return stat64([path cStringWithEncoding: [OFLocalization encoding]],
return stat64([path cStringWithEncoding: [OFLocale encoding]], buffer);
buffer);
#else
return stat([path cStringWithEncoding: [OFLocalization encoding]],
return stat([path cStringWithEncoding: [OFLocale encoding]], buffer);
buffer);
#endif
}
static int
of_lstat(OFString *path, of_stat_t *buffer)
{
#if defined(HAVE_LSTAT) && !defined(OF_WINDOWS) && !defined(OF_AMIGAOS)
# ifdef OF_HAVE_OFF64_T
return lstat64([path cStringWithEncoding: [OFLocalization encoding]],
return lstat64([path cStringWithEncoding: [OFLocale encoding]], buffer);
buffer);
# else
return lstat([path cStringWithEncoding: [OFLocalization encoding]],
return lstat([path cStringWithEncoding: [OFLocale encoding]], buffer);
buffer);
# endif
#else
return of_stat(path, buffer);
#endif
}
static void
|
︙ | | |
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
|
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
|
-
+
|
[attributes setObject: [NSNumber numberWithUInt16: s->st_gid]
forKey: of_file_attribute_key_posix_gid];
# ifdef OF_HAVE_THREADS
[passwdMutex lock];
@try {
# endif
of_string_encoding_t encoding = [OFLocalization encoding];
of_string_encoding_t encoding = [OFLocale encoding];
struct passwd *passwd = getpwuid(s->st_uid);
struct group *group_ = getgrgid(s->st_gid);
if (passwd != NULL) {
OFString *owner = [OFString
stringWithCString: passwd->pw_name
encoding: encoding];
|
︙ | | |
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
|
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
|
-
+
|
of_stat_t *s, OFURL *URL)
{
#ifdef OF_FILE_MANAGER_SUPPORTS_SYMLINKS
OFString *path = [URL fileSystemRepresentation];
# ifndef OF_WINDOWS
if (S_ISLNK(s->st_mode)) {
of_string_encoding_t encoding = [OFLocalization encoding];
of_string_encoding_t encoding = [OFLocale encoding];
char destinationC[PATH_MAX];
ssize_t length;
OFString *destination;
of_file_attribute_key_t key;
length = readlink([path cStringWithEncoding: encoding],
destinationC, PATH_MAX);
|
︙ | | |
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
|
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
|
-
+
-
|
attributes: (of_file_attributes_t)attributes
{
#ifdef OF_FILE_MANAGER_SUPPORTS_PERMISSIONS
uint16_t mode = [permissions uInt16Value] & 0777;
OFString *path = [URL fileSystemRepresentation];
# ifndef OF_WINDOWS
if (chmod([path cStringWithEncoding: [OFLocalization encoding]],
if (chmod([path cStringWithEncoding: [OFLocale encoding]], mode) != 0)
mode) != 0)
# else
if (_wchmod([path UTF16String], mode) != 0)
# endif
@throw [OFSetItemAttributesFailedException
exceptionWithURL: URL
attributes: attributes
failedAttribute: of_file_attribute_key_posix_permissions
|
︙ | | |
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
|
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
|
-
+
|
uid_t uid = -1;
gid_t gid = -1;
of_string_encoding_t encoding;
if (owner == nil && group == nil)
@throw [OFInvalidArgumentException exception];
encoding = [OFLocalization encoding];
encoding = [OFLocale encoding];
# ifdef OF_HAVE_THREADS
[passwdMutex lock];
@try {
# endif
if (owner != nil) {
struct passwd *passwd;
|
︙ | | |
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
|
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
|
-
+
|
@throw [OFCreateDirectoryFailedException
exceptionWithURL: URL
errNo: errno];
#elif defined(OF_AMIGAOS)
BPTR lock;
if ((lock = CreateDir(
[path cStringWithEncoding: [OFLocalization encoding]])) == 0) {
[path cStringWithEncoding: [OFLocale encoding]])) == 0) {
int errNo;
switch (IoErr()) {
case ERROR_NO_FREE_STORE:
case ERROR_DISK_FULL:
errNo = ENOSPC;
break;
|
︙ | | |
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
|
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
|
-
+
-
|
@throw [OFCreateDirectoryFailedException
exceptionWithURL: URL
errNo: errNo];
}
UnLock(lock);
#else
if (mkdir([path cStringWithEncoding: [OFLocalization encoding]],
if (mkdir([path cStringWithEncoding: [OFLocale encoding]], 0777) != 0)
0777) != 0)
@throw [OFCreateDirectoryFailedException
exceptionWithURL: URL
errNo: errno];
#endif
objc_autoreleasePoolPop(pool);
}
|
︙ | | |
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
|
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
|
-
+
|
@throw [OFReadFailedException exceptionWithObject: self
requestedLength: 0
errNo: EIO];
} @finally {
FindClose(handle);
}
#elif defined(OF_AMIGAOS)
of_string_encoding_t encoding = [OFLocalization encoding];
of_string_encoding_t encoding = [OFLocale encoding];
BPTR lock;
struct FileInfoBlock fib;
if ((lock = Lock([path cStringWithEncoding: encoding],
SHARED_LOCK)) == 0) {
int errNo;
|
︙ | | |
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
|
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
|
-
+
|
exceptionWithObject: self
requestedLength: 0
errNo: EIO];
} @finally {
UnLock(lock);
}
#else
of_string_encoding_t encoding = [OFLocalization encoding];
of_string_encoding_t encoding = [OFLocale encoding];
DIR *dir;
if ((dir = opendir([path cStringWithEncoding: encoding])) == NULL)
@throw [OFOpenItemFailedException exceptionWithURL: URL
mode: nil
errNo: errno];
|
︙ | | |
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
|
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
|
-
+
-
-
+
-
+
-
|
[path stringByAppendingPathComponent: item]]];
objc_autoreleasePoolPop(pool2);
}
#ifndef OF_AMIGAOS
# ifndef OF_WINDOWS
if (rmdir([path cStringWithEncoding:
if (rmdir([path cStringWithEncoding: [OFLocale encoding]]) != 0)
[OFLocalization encoding]]) != 0)
# else
if (_wrmdir([path UTF16String]) != 0)
# endif
@throw [OFRemoveItemFailedException
exceptionWithURL: URL
errNo: errno];
} else {
# ifndef OF_WINDOWS
if (unlink([path cStringWithEncoding:
[OFLocalization encoding]]) != 0)
[OFLocale encoding]]) != 0)
# else
if (_wunlink([path UTF16String]) != 0)
# endif
@throw [OFRemoveItemFailedException
exceptionWithURL: URL
errNo: errno];
#endif
}
#ifdef OF_AMIGAOS
if (!DeleteFile(
if (!DeleteFile([path cStringWithEncoding: [OFLocale encoding]])) {
[path cStringWithEncoding: [OFLocalization encoding]])) {
int errNo;
switch (IoErr()) {
case ERROR_OBJECT_IN_USE:
case ERROR_DISK_NOT_VALIDATED:
errNo = EBUSY;
break;
|
︙ | | |
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
|
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
|
-
+
|
![[destination scheme] isEqual: _scheme])
@throw [OFInvalidArgumentException exception];
sourcePath = [source fileSystemRepresentation];
destinationPath = [destination fileSystemRepresentation];
# ifndef OF_WINDOWS
of_string_encoding_t encoding = [OFLocalization encoding];
of_string_encoding_t encoding = [OFLocale encoding];
if (link([sourcePath cStringWithEncoding: encoding],
[destinationPath cStringWithEncoding: encoding]) != 0)
@throw [OFLinkFailedException
exceptionWithSourceURL: source
destinationURL: destination
errNo: errno];
|
︙ | | |
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
|
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
|
-
+
|
if (![[URL scheme] isEqual: _scheme])
@throw [OFInvalidArgumentException exception];
path = [URL fileSystemRepresentation];
# ifndef OF_WINDOWS
of_string_encoding_t encoding = [OFLocalization encoding];
of_string_encoding_t encoding = [OFLocale encoding];
if (symlink([target cStringWithEncoding: encoding],
[path cStringWithEncoding: encoding]) != 0)
@throw [OFCreateSymbolicLinkFailedException
exceptionWithURL: URL
target: target
errNo: errno];
|
︙ | | |
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
|
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
|
-
+
|
if (_wrename([[source fileSystemRepresentation] UTF16String],
[[destination fileSystemRepresentation] UTF16String]) != 0)
@throw [OFMoveItemFailedException
exceptionWithSourceURL: source
destinationURL: destination
errNo: errno];
#elif defined(OF_AMIGAOS)
of_string_encoding_t encoding = [OFLocalization encoding];
of_string_encoding_t encoding = [OFLocale encoding];
if (!Rename([[source fileSystemRepresentation]
cStringWithEncoding: encoding],
[[destination fileSystemRepresentation]
cStringWithEncoding: encoding])) {
int errNo;
|
︙ | | |
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
|
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
|
-
+
|
@throw [OFMoveItemFailedException
exceptionWithSourceURL: source
destinationURL: destination
errNo: errNo];
}
#else
of_string_encoding_t encoding = [OFLocalization encoding];
of_string_encoding_t encoding = [OFLocale encoding];
if (rename([[source fileSystemRepresentation]
cStringWithEncoding: encoding],
[[destination fileSystemRepresentation]
cStringWithEncoding: encoding]) != 0)
@throw [OFMoveItemFailedException
exceptionWithSourceURL: source
|
︙ | | |