︙ | | |
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
+
+
+
+
+
+
+
+
+
+
+
+
+
|
* file.
*/
#import "OFObject.h"
#import "OFSeekableStream.h"
OF_ASSUME_NONNULL_BEGIN
#if defined(OF_HAVE_CHMOD) && !defined(OF_MORPHOS)
# define OF_FILE_MANAGER_SUPPORTS_PERMISSIONS
#endif
#if defined(OF_HAVE_CHOWN) && !defined(OF_MORPHOS)
# define OF_FILE_MANAGER_SUPPORTS_OWNER
#endif
#if (defined(OF_HAVE_LINK) && !defined(OF_MORPHOS)) || defined(OF_WINDOWS)
# define OF_FILE_MANAGER_SUPPORTS_LINKS
#endif
#if (defined(OF_HAVE_SYMLINK) && !defined(OF_MORPHOS)) || defined(OF_WINDOWS)
# define OF_FILE_MANAGER_SUPPORTS_SYMLINKS
#endif
@class OFArray OF_GENERIC(ObjectType);
@class OFDate;
/*!
* @class OFFileManager OFFileManager.h ObjFW/OFFileManager.h
*
|
︙ | | |
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
-
+
|
* @brief Checks whether a directory exists at the specified path.
*
* @param path The path to check
* @return A boolean whether there is a directory at the specified path
*/
- (bool)directoryExistsAtPath: (OFString *)path;
#if defined(OF_HAVE_SYMLINK) || defined(OF_WINDOWS)
#ifdef OF_FILE_MANAGER_SUPPORTS_SYMLINKS
/*!
* @brief Checks whether a symbolic link exists at the specified path.
*
* @param path The path to check
* @return A boolean whether there is a symbolic link at the specified path
*/
- (bool)symbolicLinkExistsAtPath: (OFString *)path;
|
︙ | | |
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
-
+
|
* @param path The path to the item whose last status change time should be
* returned
*
* @return The last status change time of the specified item
*/
- (OFDate *)statusChangeTimeOfItemAtPath: (OFString *)path;
#ifdef OF_HAVE_CHMOD
#ifdef OF_FILE_MANAGER_SUPPORTS_PERMISSIONS
/*!
* @brief Returns the permissions of the specified item.
*
* This returns only the permissions, meaning read, write and execute for
* owner, user and group, along with the sticky, setuid and setgid bit. In
* other words, only bits that match the mask 07777.
*
|
︙ | | |
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
-
+
|
* @param path The path to the item whose permissions should be changed
* @param permissions The new permissions for the item
*/
- (void)changePermissionsOfItemAtPath: (OFString *)path
permissions: (uint16_t)permissions;
#endif
#ifdef OF_HAVE_CHOWN
#ifdef OF_FILE_MANAGER_SUPPORTS_OWNER
/*!
* @brief Get the owner and group of the specified item.
*
* @param owner A pointer to an `OFString *` to store the owner, or nil
* @param group A pointer to an `OFString *` to store the group, or nil
* @param path The path to the item whose owner and group should be retrieved
*/
|
︙ | | |
231
232
233
234
235
236
237
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
|
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
290
291
292
293
|
-
+
-
+
-
-
|
*
* If the item at the specified path is a directory, it is removed recursively.
*
* @param path The path to the item which should be removed
*/
- (void)removeItemAtPath: (OFString *)path;
#if defined(OF_HAVE_LINK) || defined(OF_WINDOWS)
#ifdef OF_FILE_MANAGER_SUPPORTS_LINKS
/*!
* @brief Creates a hard link for the specified item.
*
* The destination path must be a full path, which means it must include the
* name of the item.
*
* This method is not available on some systems.
*
* @param source The path to the item for which a link should be created
* @param destination The path to the item which should link to the source
*/
- (void)linkItemAtPath: (OFString *)source
toPath: (OFString *)destination;
#endif
#if defined(OF_HAVE_SYMLINK) || defined(OF_WINDOWS)
#ifdef OF_FILE_MANAGER_SUPPORTS_SYMLINKS
/*!
* @brief Creates a symbolic link for an item.
*
* The destination path must be a full path, which means it must include the
* name of the item.
*
* This method is not available on some systems.
*
* @note On Windows, this requires at least Windows Vista and administrator
* privileges!
*
* @param destination The path to the item which should symbolically link to the
* source
* @param source The path to the item for which a symbolic link should be
* created
*/
- (void)createSymbolicLinkAtPath: (OFString *)destination
withDestinationPath: (OFString *)source;
#endif
#if defined(OF_HAVE_READLINK) || defined(OF_WINDOWS)
/*!
* @brief Returns the destination of the symbolic link at the specified path.
*
* @param path The path to the symbolic link
*
* @note On Windows, at least Windows Vista is required.
*
|
︙ | | |
︙ | | |
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
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
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
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
|
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
-
-
-
+
-
-
-
-
|
#import "OFUnlockFailedException.h"
#ifdef OF_WINDOWS
# include <windows.h>
# include <direct.h>
# include <ntdef.h>
#endif
#ifdef OF_MORPHOS
# define BOOL EXEC_BOOL
# include <proto/dos.h>
# include <proto/locale.h>
# undef BOOL
#endif
#if defined(OF_WINDOWS)
typedef struct __stat64 of_stat_t;
#elif defined(OF_MORPHOS)
typedef struct {
of_offset_t st_size;
mode_t st_mode;
of_time_interval_t st_atime, st_mtime, st_ctime;
} of_stat_t;
#elif defined(OF_HAVE_OFF64_T)
typedef struct stat64 of_stat_t;
#else
typedef struct stat of_stat_t;
#endif
static OFFileManager *defaultManager;
#if defined(OF_HAVE_CHOWN) && defined(OF_HAVE_THREADS)
#if defined(OF_HAVE_CHOWN) && defined(OF_HAVE_THREADS) && !defined(OF_MORPHOS)
static OFMutex *passwdMutex;
#endif
#if !defined(HAVE_READDIR_R) && !defined(OF_WINDOWS) && defined(OF_HAVE_THREADS)
#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)
BPTR lock;
struct FileInfoBlock fib;
of_time_interval_t timeInterval;
struct Locale *locale;
if ((lock = Lock([path cStringWithEncoding: [OFLocalization encoding]],
SHARED_LOCK)) == 0) {
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;
}
return -1;
}
if (!Examine64(lock, &fib, TAG_DONE)) {
UnLock(lock);
errno = 0;
return -1;
}
UnLock(lock);
buffer->st_size = fib.fib_Size64;
buffer->st_mode = (fib.fib_DirEntryType > 0 ? S_IFDIR : S_IFREG);
timeInterval = 252460800; /* 1978-01-01 */
locale = OpenLocale(NULL);
/*
* FIXME: This does not take DST into account. But unfortunately, there
* is no way to figure out if DST was in effect when the file was
* modified.
*/
timeInterval += locale->loc_GMTOffset * 60.0;
CloseLocale(locale);
timeInterval += fib.fib_Date.ds_Days * 86400.0;
timeInterval += fib.fib_Date.ds_Minute * 60.0;
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]],
buffer);
#else
return stat([path cStringWithEncoding: [OFLocalization encoding]],
buffer);
#endif
}
static int
of_lstat(OFString *path, of_stat_t *buffer)
{
#if defined(OF_WINDOWS)
return _wstat64([path UTF16String], buffer);
#elif defined(HAVE_LSTAT)
#if defined(HAVE_LSTAT) && !defined(OF_WINDOWS) && !defined(OF_MORPHOS)
# ifdef OF_HAVE_OFF64_T
return lstat64([path cStringWithEncoding: [OFLocalization encoding]],
buffer);
# else
return lstat([path cStringWithEncoding: [OFLocalization encoding]],
buffer);
# endif
#else
# ifdef OF_HAVE_OFF64_T
return stat64([path cStringWithEncoding: [OFLocalization encoding]],
buffer);
return of_stat(path, buffer);
# else
return stat([path cStringWithEncoding: [OFLocalization encoding]],
buffer);
# endif
#endif
}
@implementation OFFileManager
+ (void)initialize
{
#ifdef OF_WINDOWS
|
︙ | | |
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
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
|
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
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
|
-
+
-
-
-
-
+
-
-
+
-
-
-
+
+
-
+
-
+
-
-
+
-
-
-
-
-
+
|
if (path == nil)
@throw [OFInvalidArgumentException exception];
if (of_stat(path, &s) == -1)
return false;
if (S_ISREG(s.st_mode))
return S_ISREG(s.st_mode);
return true;
return false;
}
- (bool)directoryExistsAtPath: (OFString *)path
{
of_stat_t s;
if (path == nil)
@throw [OFInvalidArgumentException exception];
if (of_stat(path, &s) == -1)
return false;
if (S_ISDIR(s.st_mode))
return S_ISDIR(s.st_mode);
return true;
}
return false;
}
#ifdef OF_FILE_MANAGER_SUPPORTS_SYMLINKS
#if defined(OF_HAVE_SYMLINK)
- (bool)symbolicLinkExistsAtPath: (OFString *)path
{
# ifndef OF_WINDOWS
of_stat_t s;
if (path == nil)
@throw [OFInvalidArgumentException exception];
if (of_lstat(path, &s) == -1)
return false;
if (S_ISLNK(s.st_mode))
return S_ISLNK(s.st_mode);
return true;
# else
return false;
}
#elif defined(OF_WINDOWS)
- (bool)symbolicLinkExistsAtPath: (OFString *)path
{
WIN32_FIND_DATAW data;
if (!FindFirstFileW([path UTF16String], &data))
return false;
if ((data.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) &&
data.dwReserved0 == IO_REPARSE_TAG_SYMLINK)
return true;
return false;
# endif
}
#endif
- (void)createDirectoryAtPath: (OFString *)path
{
if (path == nil)
@throw [OFInvalidArgumentException exception];
|
︙ | | |
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
|
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
|
-
+
|
@throw [OFStatItemFailedException exceptionWithPath: path
errNo: errno];
/* FIXME: We could be more precise on some OSes */
return [OFDate dateWithTimeIntervalSince1970: s.st_ctime];
}
#ifdef OF_HAVE_CHMOD
#ifdef OF_FILE_MANAGER_SUPPORTS_PERMISSIONS
- (uint16_t)permissionsOfItemAtPath: (OFString *)path
{
of_stat_t s;
if (path == nil)
@throw [OFInvalidArgumentException exception];
|
︙ | | |
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
|
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
|
-
+
|
@throw [OFChangePermissionsFailedException
exceptionWithPath: path
permissions: permissions
errNo: errno];
}
#endif
#ifdef OF_HAVE_CHOWN
#ifdef OF_FILE_MANAGER_SUPPORTS_OWNER
- (void)getOwner: (OFString **)owner
group: (OFString **)group
ofItemAtPath: (OFString *)path
{
of_stat_t s;
if (path == nil)
|
︙ | | |
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
|
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
|
-
+
|
*group = [OFString stringWithCString: group_->gr_name
encoding: encoding];
}
# ifdef OF_HAVE_THREADS
} @finally {
[passwdMutex unlock];
}
#endif
# endif
}
- (void)changeOwnerOfItemAtPath: (OFString *)path
owner: (OFString *)owner
group: (OFString *)group
{
uid_t uid = -1;
|
︙ | | |
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
|
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
|
-
+
|
errNo: errno];
if (S_ISDIR(s.st_mode)) {
OFArray *contents;
@try {
[self createDirectoryAtPath: destination];
#ifdef OF_HAVE_CHMOD
#ifdef OF_FILE_MANAGER_SUPPORTS_PERMISSIONS
[self changePermissionsOfItemAtPath: destination
permissions: s.st_mode];
#endif
contents = [self contentsOfDirectoryAtPath: source];
} @catch (id e) {
/*
|
︙ | | |
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
|
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
|
-
+
|
length = [sourceFile readIntoBuffer: buffer
length: pageSize];
[destinationFile writeBuffer: buffer
length: length];
}
#ifdef OF_HAVE_CHMOD
#ifdef OF_FILE_MANAGER_SUPPORTS_PERMISSIONS
[self changePermissionsOfItemAtPath: destination
permissions: s.st_mode];
#endif
} @catch (id e) {
/*
* Only convert exceptions to OFCopyItemFailedException
* that have an errNo property. This covers all I/O
|
︙ | | |
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
|
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
|
-
+
|
@throw e;
} @finally {
[sourceFile close];
[destinationFile close];
free(buffer);
}
#ifdef OF_HAVE_SYMLINK
#ifdef OF_FILE_MANAGER_SUPPORTS_SYMLINKS
} else if (S_ISLNK(s.st_mode)) {
@try {
source = [self destinationOfSymbolicLinkAtPath: source];
[self createSymbolicLinkAtPath: destination
withDestinationPath: source];
} @catch (id e) {
|
︙ | | |
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
|
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
|
-
-
-
-
+
|
}
- (void)moveItemAtPath: (OFString *)source
toPath: (OFString *)destination
{
void *pool;
of_stat_t s;
#ifndef OF_WINDOWS
of_string_encoding_t encoding;
#endif
if (source == nil || destination == nil)
@throw [OFInvalidArgumentException exception];
pool = objc_autoreleasePoolPush();
if (of_lstat(destination, &s) == 0)
@throw [OFCopyItemFailedException
exceptionWithSourcePath: source
destinationPath: destination
errNo: EEXIST];
#ifndef OF_WINDOWS
encoding = [OFLocalization encoding];
of_string_encoding_t encoding = [OFLocalization encoding];
if (rename([source cStringWithEncoding: encoding],
[destination cStringWithEncoding: encoding]) != 0) {
#else
if (_wrename([source UTF16String], [destination UTF16String]) != 0) {
#endif
if (errno != EXDEV)
|
︙ | | |
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
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
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
|
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
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
|
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
+
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
+
+
+
+
-
-
-
-
-
+
-
-
-
-
-
|
exceptionWithPath: path
errNo: errno];
}
objc_autoreleasePoolPop(pool);
}
#if defined(OF_HAVE_LINK)
- (void)linkItemAtPath: (OFString *)source
toPath: (OFString *)destination
{
void *pool;
of_string_encoding_t encoding;
#ifdef OF_FILE_MANAGER_SUPPORTS_LINKS
if (source == nil || destination == nil)
@throw [OFInvalidArgumentException exception];
pool = objc_autoreleasePoolPush();
encoding = [OFLocalization encoding];
if (link([source cStringWithEncoding: encoding],
[destination cStringWithEncoding: encoding]) != 0)
@throw [OFLinkFailedException
exceptionWithSourcePath: source
destinationPath: destination
errNo: errno];
objc_autoreleasePoolPop(pool);
}
#elif defined(OF_WINDOWS)
- (void)linkItemAtPath: (OFString *)source
toPath: (OFString *)destination
{
void *pool;
if (source == nil || destination == nil)
@throw [OFInvalidArgumentException exception];
pool = objc_autoreleasePoolPush();
# ifndef OF_WINDOWS
of_string_encoding_t encoding = [OFLocalization encoding];
if (link([source cStringWithEncoding: encoding],
[destination cStringWithEncoding: encoding]) != 0)
@throw [OFLinkFailedException
exceptionWithSourcePath: source
destinationPath: destination
errNo: errno];
# else
if (!CreateHardLinkW([destination UTF16String],
[source UTF16String], NULL))
@throw [OFLinkFailedException
exceptionWithSourcePath: source
destinationPath: destination
errNo: 0];
# endif
objc_autoreleasePoolPop(pool);
}
#endif
#if defined(OF_HAVE_SYMLINK)
#ifdef OF_FILE_MANAGER_SUPPORTS_SYMLINKS
- (void)createSymbolicLinkAtPath: (OFString *)destination
withDestinationPath: (OFString *)source
{
void *pool;
of_string_encoding_t encoding;
if (source == nil || destination == nil)
@throw [OFInvalidArgumentException exception];
pool = objc_autoreleasePoolPush();
# ifndef OF_WINDOWS
encoding = [OFLocalization encoding];
of_string_encoding_t encoding = [OFLocalization encoding];
if (symlink([source cStringWithEncoding: encoding],
[destination cStringWithEncoding: encoding]) != 0)
@throw [OFCreateSymbolicLinkFailedException
exceptionWithSourcePath: source
destinationPath: destination
errNo: errno];
# else
objc_autoreleasePoolPop(pool);
}
#elif defined(OF_WINDOWS)
- (void)createSymbolicLinkAtPath: (OFString *)destination
withDestinationPath: (OFString *)source
{
void *pool;
if (func_CreateSymbolicLinkW == NULL)
@throw [OFNotImplementedException exceptionWithSelector: _cmd
object: self];
if (source == nil || destination == nil)
@throw [OFInvalidArgumentException exception];
pool = objc_autoreleasePoolPush();
if (!func_CreateSymbolicLinkW([destination UTF16String],
[source UTF16String], 0))
@throw [OFCreateSymbolicLinkFailedException
exceptionWithSourcePath: source
destinationPath: destination
errNo: 0];
# endif
objc_autoreleasePoolPop(pool);
}
#endif
#ifdef OF_HAVE_READLINK
- (OFString *)destinationOfSymbolicLinkAtPath: (OFString *)path
{
if (path == nil)
@throw [OFInvalidArgumentException exception];
# ifndef OF_WINDOWS
char destination[PATH_MAX];
ssize_t length;
of_string_encoding_t encoding;
if (path == nil)
@throw [OFInvalidArgumentException exception];
encoding = [OFLocalization encoding];
length = readlink([path cStringWithEncoding: encoding],
destination, PATH_MAX);
if (length < 0)
@throw [OFStatItemFailedException exceptionWithPath: path
errNo: errno];
return [OFString stringWithCString: destination
encoding: encoding
length: length];
}
#elif defined(OF_WINDOWS)
# else
- (OFString *)destinationOfSymbolicLinkAtPath: (OFString *)path
{
HANDLE handle;
/* Check if we're on a version that actually supports symlinks. */
if (func_CreateSymbolicLinkW == NULL)
@throw [OFNotImplementedException exceptionWithSelector: _cmd
object: self];
if (path == nil)
@throw [OFInvalidArgumentException exception];
if ((handle = CreateFileW([path UTF16String], 0,
(FILE_SHARE_READ | FILE_SHARE_WRITE), NULL, OPEN_EXISTING,
FILE_FLAG_OPEN_REPARSE_POINT, NULL)) == INVALID_HANDLE_VALUE)
@throw [OFStatItemFailedException exceptionWithPath: path
errNo: 0];
@try {
|
︙ | | |
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
|
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
|
-
+
-
+
+
|
errNo: 0];
if (buffer.data.ReparseTag != IO_REPARSE_TAG_SYMLINK)
@throw [OFStatItemFailedException
exceptionWithPath: path
errNo: 0];
#define slrb buffer.data.SymbolicLinkReparseBuffer
# define slrb buffer.data.SymbolicLinkReparseBuffer
tmp = slrb.PathBuffer +
(slrb.SubstituteNameOffset / sizeof(wchar_t));
return [OFString
stringWithUTF16String: tmp
length: slrb.SubstituteNameLength /
sizeof(wchar_t)];
#undef slrb
# undef slrb
} @finally {
CloseHandle(handle);
}
# endif
}
#endif
@end
|