comparison dstep/foundation/NSFileManager.d @ 16:19885b43130e

Huge update, the bridge actually works now
author Jacob Carlborg <doob@me.com>
date Sun, 03 Jan 2010 22:06:11 +0100
parents 7ff919f595d5
children b9de51448c6b
comparison
equal deleted inserted replaced
15:7ff919f595d5 16:19885b43130e
9 import dstep.corefoundation.CFBase; 9 import dstep.corefoundation.CFBase;
10 import dstep.foundation.NSArray; 10 import dstep.foundation.NSArray;
11 import dstep.foundation.NSData; 11 import dstep.foundation.NSData;
12 import dstep.foundation.NSDate; 12 import dstep.foundation.NSDate;
13 import dstep.foundation.NSDictionary; 13 import dstep.foundation.NSDictionary;
14 import dstep.foundation.NSDirectoryEnumerator;
15 import dstep.foundation.NSEnumerator; 14 import dstep.foundation.NSEnumerator;
16 import dstep.foundation.NSError; 15 import dstep.foundation.NSError;
17 import dstep.foundation.NSNumber; 16 import dstep.foundation.NSObjCRuntime;
18 import dstep.foundation.NSObject; 17 import dstep.foundation.NSObject;
18 import dstep.foundation.NSString;
19 import dstep.foundation.NSValue;
19 import dstep.objc.bridge.Bridge; 20 import dstep.objc.bridge.Bridge;
20 import dstep.objc.objc : id; 21 import dstep.objc.objc;
21 22
22 import bindings = dstep.foundation.NSFileManager_bindings; 23 import bindings = dstep.foundation.NSFileManager_bindings;
23 24
24 const NSString NSFileType; 25 private
25 const NSString NSFileTypeDirectory; 26 {
26 const NSString NSFileTypeRegular; 27 NSString NSFileType_;
27 const NSString NSFileTypeSymbolicLink; 28 NSString NSFileTypeDirectory_;
28 const NSString NSFileTypeSocket; 29 NSString NSFileTypeRegular_;
29 const NSString NSFileTypeCharacterSpecial; 30 NSString NSFileTypeSymbolicLink_;
30 const NSString NSFileTypeBlockSpecial; 31 NSString NSFileTypeSocket_;
31 const NSString NSFileTypeUnknown; 32 NSString NSFileTypeCharacterSpecial_;
32 const NSString NSFileSize; 33 NSString NSFileTypeBlockSpecial_;
33 const NSString NSFileModificationDate; 34 NSString NSFileTypeUnknown_;
34 const NSString NSFileReferenceCount; 35 NSString NSFileSize_;
35 const NSString NSFileDeviceIdentifier; 36 NSString NSFileModificationDate_;
36 const NSString NSFileOwnerAccountName; 37 NSString NSFileReferenceCount_;
37 const NSString NSFileGroupOwnerAccountName; 38 NSString NSFileDeviceIdentifier_;
38 const NSString NSFilePosixPermissions; 39 NSString NSFileOwnerAccountName_;
39 const NSString NSFileSystemNumber; 40 NSString NSFileGroupOwnerAccountName_;
40 const NSString NSFileSystemFileNumber; 41 NSString NSFilePosixPermissions_;
41 const NSString NSFileExtensionHidden; 42 NSString NSFileSystemNumber_;
42 const NSString NSFileHFSCreatorCode; 43 NSString NSFileSystemFileNumber_;
43 const NSString NSFileHFSTypeCode; 44 NSString NSFileExtensionHidden_;
44 const NSString NSFileImmutable; 45 NSString NSFileHFSCreatorCode_;
45 const NSString NSFileAppendOnly; 46 NSString NSFileHFSTypeCode_;
46 const NSString NSFileCreationDate; 47 NSString NSFileImmutable_;
47 const NSString NSFileOwnerAccountID; 48 NSString NSFileAppendOnly_;
48 const NSString NSFileGroupOwnerAccountID; 49 NSString NSFileCreationDate_;
49 const NSString NSFileBusy; 50 NSString NSFileOwnerAccountID_;
50 const NSString NSFileSystemSize; 51 NSString NSFileGroupOwnerAccountID_;
51 const NSString NSFileSystemFreeSize; 52 NSString NSFileBusy_;
52 const NSString NSFileSystemNodes; 53 NSString NSFileSystemSize_;
53 const NSString NSFileSystemFreeNodes; 54 NSString NSFileSystemFreeSize_;
54 55 NSString NSFileSystemNodes_;
55 static this () 56 NSString NSFileSystemFreeNodes_;
56 { 57 }
57 NSFileType = new NSString(bindings.NSFileType); 58
58 NSFileTypeDirectory = new NSString(bindings.NSFileTypeDirectory); 59 NSString NSFileType ()
59 NSFileTypeRegular = new NSString(bindings.NSFileTypeRegular); 60 {
60 NSFileTypeSymbolicLink = new NSString(bindings.NSFileTypeSymbolicLink); 61 if (NSFileType_)
61 NSFileTypeSocket = new NSString(bindings.NSFileTypeSocket); 62 return NSFileType_;
62 NSFileTypeCharacterSpecial = new NSString(bindings.NSFileTypeCharacterSpecial); 63
63 NSFileTypeBlockSpecial = new NSString(bindings.NSFileTypeBlockSpecial); 64 return NSFileType_ = new NSString(bindings.NSFileType);
64 NSFileTypeUnknown = new NSString(bindings.NSFileTypeUnknown); 65 }
65 NSFileSize = new NSString(bindings.NSFileSize); 66
66 NSFileModificationDate = new NSString(bindings.NSFileModificationDate); 67 NSString NSFileTypeDirectory ()
67 NSFileReferenceCount = new NSString(bindings.NSFileReferenceCount); 68 {
68 NSFileDeviceIdentifier = new NSString(bindings.NSFileDeviceIdentifier); 69 if (NSFileTypeDirectory_)
69 NSFileOwnerAccountName = new NSString(bindings.NSFileOwnerAccountName); 70 return NSFileTypeDirectory_;
70 NSFileGroupOwnerAccountName = new NSString(bindings.NSFileGroupOwnerAccountName); 71
71 NSFilePosixPermissions = new NSString(bindings.NSFilePosixPermissions); 72 return NSFileTypeDirectory_ = new NSString(bindings.NSFileTypeDirectory);
72 NSFileSystemNumber = new NSString(bindings.NSFileSystemNumber); 73 }
73 NSFileSystemFileNumber = new NSString(bindings.NSFileSystemFileNumber); 74
74 NSFileExtensionHidden = new NSString(bindings.NSFileExtensionHidden); 75 NSString NSFileTypeRegular ()
75 NSFileHFSCreatorCode = new NSString(bindings.NSFileHFSCreatorCode); 76 {
76 NSFileHFSTypeCode = new NSString(bindings.NSFileHFSTypeCode); 77 if (NSFileTypeRegular_)
77 NSFileImmutable = new NSString(bindings.NSFileImmutable); 78 return NSFileTypeRegular_;
78 NSFileAppendOnly = new NSString(bindings.NSFileAppendOnly); 79
79 NSFileCreationDate = new NSString(bindings.NSFileCreationDate); 80 return NSFileTypeRegular_ = new NSString(bindings.NSFileTypeRegular);
80 NSFileOwnerAccountID = new NSString(bindings.NSFileOwnerAccountID); 81 }
81 NSFileGroupOwnerAccountID = new NSString(bindings.NSFileGroupOwnerAccountID); 82
82 NSFileBusy = new NSString(bindings.NSFileBusy); 83 NSString NSFileTypeSymbolicLink ()
83 NSFileSystemSize = new NSString(bindings.NSFileSystemSize); 84 {
84 NSFileSystemFreeSize = new NSString(bindings.NSFileSystemFreeSize); 85 if (NSFileTypeSymbolicLink_)
85 NSFileSystemNodes = new NSString(bindings.NSFileSystemNodes); 86 return NSFileTypeSymbolicLink_;
86 NSFileSystemFreeNodes = new NSString(bindings.NSFileSystemFreeNodes); 87
87 } 88 return NSFileTypeSymbolicLink_ = new NSString(bindings.NSFileTypeSymbolicLink);
89 }
90
91 NSString NSFileTypeSocket ()
92 {
93 if (NSFileTypeSocket_)
94 return NSFileTypeSocket_;
95
96 return NSFileTypeSocket_ = new NSString(bindings.NSFileTypeSocket);
97 }
98
99 NSString NSFileTypeCharacterSpecial ()
100 {
101 if (NSFileTypeCharacterSpecial_)
102 return NSFileTypeCharacterSpecial_;
103
104 return NSFileTypeCharacterSpecial_ = new NSString(bindings.NSFileTypeCharacterSpecial);
105 }
106
107 NSString NSFileTypeBlockSpecial ()
108 {
109 if (NSFileTypeBlockSpecial_)
110 return NSFileTypeBlockSpecial_;
111
112 return NSFileTypeBlockSpecial_ = new NSString(bindings.NSFileTypeBlockSpecial);
113 }
114
115 NSString NSFileTypeUnknown ()
116 {
117 if (NSFileTypeUnknown_)
118 return NSFileTypeUnknown_;
119
120 return NSFileTypeUnknown_ = new NSString(bindings.NSFileTypeUnknown);
121 }
122
123 NSString NSFileSize ()
124 {
125 if (NSFileSize_)
126 return NSFileSize_;
127
128 return NSFileSize_ = new NSString(bindings.NSFileSize);
129 }
130
131 NSString NSFileModificationDate ()
132 {
133 if (NSFileModificationDate_)
134 return NSFileModificationDate_;
135
136 return NSFileModificationDate_ = new NSString(bindings.NSFileModificationDate);
137 }
138
139 NSString NSFileReferenceCount ()
140 {
141 if (NSFileReferenceCount_)
142 return NSFileReferenceCount_;
143
144 return NSFileReferenceCount_ = new NSString(bindings.NSFileReferenceCount);
145 }
146
147 NSString NSFileDeviceIdentifier ()
148 {
149 if (NSFileDeviceIdentifier_)
150 return NSFileDeviceIdentifier_;
151
152 return NSFileDeviceIdentifier_ = new NSString(bindings.NSFileDeviceIdentifier);
153 }
154
155 NSString NSFileOwnerAccountName ()
156 {
157 if (NSFileOwnerAccountName_)
158 return NSFileOwnerAccountName_;
159
160 return NSFileOwnerAccountName_ = new NSString(bindings.NSFileOwnerAccountName);
161 }
162
163 NSString NSFileGroupOwnerAccountName ()
164 {
165 if (NSFileGroupOwnerAccountName_)
166 return NSFileGroupOwnerAccountName_;
167
168 return NSFileGroupOwnerAccountName_ = new NSString(bindings.NSFileGroupOwnerAccountName);
169 }
170
171 NSString NSFilePosixPermissions ()
172 {
173 if (NSFilePosixPermissions_)
174 return NSFilePosixPermissions_;
175
176 return NSFilePosixPermissions_ = new NSString(bindings.NSFilePosixPermissions);
177 }
178
179 NSString NSFileSystemNumber ()
180 {
181 if (NSFileSystemNumber_)
182 return NSFileSystemNumber_;
183
184 return NSFileSystemNumber_ = new NSString(bindings.NSFileSystemNumber);
185 }
186
187 NSString NSFileSystemFileNumber ()
188 {
189 if (NSFileSystemFileNumber_)
190 return NSFileSystemFileNumber_;
191
192 return NSFileSystemFileNumber_ = new NSString(bindings.NSFileSystemFileNumber);
193 }
194
195 NSString NSFileExtensionHidden ()
196 {
197 if (NSFileExtensionHidden_)
198 return NSFileExtensionHidden_;
199
200 return NSFileExtensionHidden_ = new NSString(bindings.NSFileExtensionHidden);
201 }
202
203 NSString NSFileHFSCreatorCode ()
204 {
205 if (NSFileHFSCreatorCode_)
206 return NSFileHFSCreatorCode_;
207
208 return NSFileHFSCreatorCode_ = new NSString(bindings.NSFileHFSCreatorCode);
209 }
210
211 NSString NSFileHFSTypeCode ()
212 {
213 if (NSFileHFSTypeCode_)
214 return NSFileHFSTypeCode_;
215
216 return NSFileHFSTypeCode_ = new NSString(bindings.NSFileHFSTypeCode);
217 }
218
219 NSString NSFileImmutable ()
220 {
221 if (NSFileImmutable_)
222 return NSFileImmutable_;
223
224 return NSFileImmutable_ = new NSString(bindings.NSFileImmutable);
225 }
226
227 NSString NSFileAppendOnly ()
228 {
229 if (NSFileAppendOnly_)
230 return NSFileAppendOnly_;
231
232 return NSFileAppendOnly_ = new NSString(bindings.NSFileAppendOnly);
233 }
234
235 NSString NSFileCreationDate ()
236 {
237 if (NSFileCreationDate_)
238 return NSFileCreationDate_;
239
240 return NSFileCreationDate_ = new NSString(bindings.NSFileCreationDate);
241 }
242
243 NSString NSFileOwnerAccountID ()
244 {
245 if (NSFileOwnerAccountID_)
246 return NSFileOwnerAccountID_;
247
248 return NSFileOwnerAccountID_ = new NSString(bindings.NSFileOwnerAccountID);
249 }
250
251 NSString NSFileGroupOwnerAccountID ()
252 {
253 if (NSFileGroupOwnerAccountID_)
254 return NSFileGroupOwnerAccountID_;
255
256 return NSFileGroupOwnerAccountID_ = new NSString(bindings.NSFileGroupOwnerAccountID);
257 }
258
259 NSString NSFileBusy ()
260 {
261 if (NSFileBusy_)
262 return NSFileBusy_;
263
264 return NSFileBusy_ = new NSString(bindings.NSFileBusy);
265 }
266
267 NSString NSFileSystemSize ()
268 {
269 if (NSFileSystemSize_)
270 return NSFileSystemSize_;
271
272 return NSFileSystemSize_ = new NSString(bindings.NSFileSystemSize);
273 }
274
275 NSString NSFileSystemFreeSize ()
276 {
277 if (NSFileSystemFreeSize_)
278 return NSFileSystemFreeSize_;
279
280 return NSFileSystemFreeSize_ = new NSString(bindings.NSFileSystemFreeSize);
281 }
282
283 NSString NSFileSystemNodes ()
284 {
285 if (NSFileSystemNodes_)
286 return NSFileSystemNodes_;
287
288 return NSFileSystemNodes_ = new NSString(bindings.NSFileSystemNodes);
289 }
290
291 NSString NSFileSystemFreeNodes ()
292 {
293 if (NSFileSystemFreeNodes_)
294 return NSFileSystemFreeNodes_;
295
296 return NSFileSystemFreeNodes_ = new NSString(bindings.NSFileSystemFreeNodes);
297 }
298
299 const TNSFileManagerFileOperationAdditions = `
300
301 bool fileManager (NSFileManager fileManager, NSString srcPath, NSString dstPath)
302 {
303 return invokeObjcSelf!(bool, "fileManager:shouldCopyItemAtPath:toPath:dstPath:", NSFileManager, NSString, NSString);
304 }
305
306 bool fileManager (NSFileManager fileManager, NSError error, NSString srcPath, NSString dstPath)
307 {
308 return invokeObjcSelf!(bool, "fileManager:shouldProceedAfterError:copyingItemAtPath:toPath:", NSFileManager, NSError, NSString, NSString)(fileManager, error, srcPath, dstPath);
309 }
310
311 bool fileManager (NSFileManager fileManager, NSString srcPath, NSString dstPath)
312 {
313 return invokeObjcSelf!(bool, "fileManager:shouldMoveItemAtPath:toPath:", NSFileManager, NSString, NSString)(fileManager, srcPath, dstPath);
314 }
315
316 bool fileManager (NSFileManager fileManager, NSError error, NSString srcPath, NSString dstPath)
317 {
318 return invokeObjcSelf!(bool, "fileManager:shouldProceedAfterError:movingItemAtPath:toPath:", NSFileManager, NSError, NSString, NSString)(fileManager, error, srcPath, dstPath);
319 }
320
321 bool fileManager (NSFileManager fileManager, NSString srcPath, NSString dstPath)
322 {
323 return invokeObjcSelf!(bool, "fileManager:shouldLinkItemAtPath:toPath:", NSFileManager, NSString, NSString)(fileManager, srcPath, dstPath);
324 }
325
326 bool fileManager (NSFileManager fileManager, NSError error, NSString srcPath, NSString dstPath)
327 {
328 return invokeObjcSelf!(bool, "fileManager:shouldProceedAfterError:linkingItemAtPath:toPath", NSFileManager, NSError, NSString, NSString)(fileManager, error, srcPath, dstPath);
329 }
330
331 bool fileManager (NSFileManager fileManager, NSString path)
332 {
333 return invokeObjcSelf!(bool, "fileManager:shouldRemoveItemAtPath:", NSFileManager, NSString)(fileManager, path);
334 }
335
336 bool fileManager (NSFileManager fileManager, NSError error, NSString path)
337 {
338 return invokeObjcSelf!(bool, "fileManager:shouldProceedAfterError:removingItemAtPath:", NSFileManager, NSError, NSString)(fileManager, error, path);
339 }
340
341 //mixin ObjcBindMethod!(fileManager, bool, "fileManager:shouldCopyItemAtPath:toPath:dstPath:", NSFileManager, NSString, NSString);
342 //mixin ObjcBindMethod!(fileManager, bool, "fileManager:shouldProceedAfterError:copyingItemAtPath:toPath:", NSFileManager, NSError, NSString, NSString);
343 //mixin ObjcBindMethod!(fileManager, bool, "fileManager:shouldMoveItemAtPath:toPath:", NSFileManager, NSString, NSString);
344 //mixin ObjcBindMethod!(fileManager, bool, "fileManager:shouldProceedAfterError:movingItemAtPath:toPath:", NSFileManager, NSError, NSString, NSString);
345 //mixin ObjcBindMethod!(fileManager, bool, "fileManager:shouldLinkItemAtPath:toPath:", NSFileManager, NSString, NSString);
346 //mixin ObjcBindMethod!(fileManager, bool, "fileManager:shouldProceedAfterError:linkingItemAtPath:toPath", NSFileManager, NSError, NSString, NSString);
347 //mixin ObjcBindMethod!(fileManager, bool, "fileManager:shouldRemoveItemAtPath:", NSFileManager, NSString);
348 //mixin ObjcBindMethod!(fileManager, bool, "fileManager:shouldProceedAfterError:removingItemAtPath:", NSFileManager, NSError, NSString);
349 `;
350
351 const TNSCopyLinkMoveHandler = `
352
353 bool fileManager (NSFileManager fm, NSDictionary errorInfo)
354 {
355 return invokeObjcSelf!(bool, "fileManager:shouldProceedAfterError:", NSFileManager, NSDictionary)(fm, errorInfo);
356 }
357
358 void fileManager (NSFileManager fm, NSString path)
359 {
360 return invokeObjcSelf!(void, "fileManager:willProcessPath:", NSFileManager, NSString)(fm, path);
361 }
362
363 //mixin ObjcBindMethod!(fileManager, "fileManager:shouldProceedAfterError:");
364 //mixin ObjcBindMethod!(fileManager, "fileManager:willProcessPath:");
365 `;
366
367 const TNSFileAttributes = `
368
369 ulong fileSize ()
370 {
371 return invokeObjcSelf!(ulong, "fileSize");
372 }
373
374 NSDate fileModificationDate ()
375 {
376 return invokeObjcSelf!(NSDate, "fileModificationDate");
377 }
378
379 NSString fileType ()
380 {
381 return invokeObjcSelf!(NSString, "fileType");
382 }
383
384 NSUInteger filePosixPermissions ()
385 {
386 return invokeObjcSelf!(NSUInteger, "filePosixPermissions");
387 }
388
389 NSString fileOwnerAccountName ()
390 {
391 return invokeObjcSelf!(NSString, "fileOwnerAccountName");
392 }
393
394 NSString fileGroupOwnerAccountName ()
395 {
396 return invokeObjcSelf!(NSString, "fileGroupOwnerAccountName");
397 }
398
399 NSInteger fileSystemNumber ()
400 {
401 return invokeObjcSelf!(NSInteger, "fileSystemNumber");
402 }
403
404 NSUInteger fileSystemFileNumber ()
405 {
406 return invokeObjcSelf!(NSUInteger, "fileSystemFileNumber");
407 }
408
409 bool fileExtensionHidden ()
410 {
411 return invokeObjcSelf!(bool, "fileExtensionHidden");
412 }
413
414 uint fileHFSCreatorCode ()
415 {
416 return invokeObjcSelf!(uint, "fileHFSCreatorCode");
417 }
418
419 uint fileHFSTypeCode ()
420 {
421 return invokeObjcSelf!(uint, "fileHFSTypeCode");
422 }
423
424 bool fileIsImmutable ()
425 {
426 return invokeObjcSelf!(bool, "fileIsImmutable");
427 }
428
429 bool fileIsAppendOnly ()
430 {
431 return invokeObjcSelf!(bool, "fileIsAppendOnly");
432 }
433
434 NSDate fileCreationDate ()
435 {
436 return invokeObjcSelf!(NSDate, "fileCreationDate");
437 }
438
439 NSNumber fileOwnerAccountID ()
440 {
441 return invokeObjcSelf!(NSNumber, "fileOwnerAccountID");
442 }
443
444 NSNumber fileGroupOwnerAccountID ()
445 {
446 return invokeObjcSelf!(NSNumber, "fileGroupOwnerAccountID");
447 }
448 `;
88 449
89 class NSFileManager : NSObject 450 class NSFileManager : NSObject
90 { 451 {
91 mixin ObjcWrap; 452 mixin (ObjcWrap);
453
454 this ()
455 {
456 super(typeof(this).alloc.init.objcObject);
457 }
458
459 typeof(this) init ()
460 {
461 return invokeObjcSelf!(typeof(this), "init");
462 }
92 463
93 static NSFileManager defaultManager () 464 static NSFileManager defaultManager ()
94 { 465 {
95 return invokeObjcSelfClass!(NSFileManager, "defaultManager"); 466 return invokeObjcSuperClass!(NSFileManager, "defaultManager");
96 } 467 }
97 468
98 void setDelegate (Object delegate_) 469 void setDelegate (Object delegate_)
99 { 470 {
100 return invokeObjcSelf!(void, "setDelegate:", Object)(delegate_); 471 return invokeObjcSelf!(void, "setDelegate:", Object)(delegate_);
103 Object delegate_ () 474 Object delegate_ ()
104 { 475 {
105 return invokeObjcSelf!(Object, "delegate"); 476 return invokeObjcSelf!(Object, "delegate");
106 } 477 }
107 478
108 bool setAttributes (NSDictionary attributes, NSString path, NSError** error) 479 bool setAttributes (NSDictionary attributes, NSString path, ref NSError error)
109 { 480 {
110 return invokeObjcSelf!(bool, "setAttributes:ofItemAtPath:error:", NSDictionary, NSString, NSError**)(attributes, path, error); 481 id err;
111 } 482
112 483 if (error)
113 bool createDirectoryAtPath (NSString path, bool createIntermediates, NSDictionary attributes, NSError** error) 484 err = new objc_object;
114 { 485
115 return invokeObjcSelf!(bool, "createDirectoryAtPath:withIntermediateDirectories:attributes:error:", NSString, bool, NSDictionary, NSError**)(path, createIntermediates, attributes, error); 486 bool result = invokeObjcSelf!(bool, "setAttributes:ofItemAtPath:error:", NSDictionary, NSString, id*)(attributes, path, &err);
116 } 487
117 488 if (err)
118 NSArray contentsOfDirectoryAtPath (NSString path, NSError** error) 489 error = new NSError(err);
119 { 490
120 return invokeObjcSelf!(NSArray, "contentsOfDirectoryAtPath:error:", NSString, NSError**)(path, error); 491 return result;
121 } 492 }
122 493
123 NSArray subpathsOfDirectoryAtPath (NSString path, NSError** error) 494 bool createDirectoryAtPath (NSString path, bool createIntermediates, NSDictionary attributes, ref NSError error)
124 { 495 {
125 return invokeObjcSelf!(NSArray, "subpathsOfDirectoryAtPath:error:", NSString, NSError**)(path, error); 496 id err;
126 } 497
127 498 if (error)
128 NSDictionary attributesOfItemAtPath (NSString path, NSError** error) 499 err = new objc_object;
129 { 500
130 return invokeObjcSelf!(NSDictionary, "attributesOfItemAtPath:error:", NSString, NSError**)(path, error); 501 bool result = invokeObjcSelf!(bool, "createDirectoryAtPath:withIntermediateDirectories:attributes:error:", NSString, bool, NSDictionary, id*)(path, createIntermediates, attributes, &err);
131 } 502
132 503 if (err)
133 NSDictionary attributesOfFileSystemForPath (NSString path, NSError** error) 504 error = new NSError(err);
134 { 505
135 return invokeObjcSelf!(NSDictionary, "attributesOfFileSystemForPath:error:", NSString, NSError**)(path, error); 506 return result;
136 } 507 }
137 508
138 bool createSymbolicLinkAtPath (NSString path, NSString destPath, NSError** error) 509 NSArray contentsOfDirectoryAtPath (NSString path, ref NSError error)
139 { 510 {
140 return invokeObjcSelf!(bool, "createSymbolicLinkAtPath:withDestinationPath:error:", NSString, NSString, NSError**)(path, destPath, error); 511 id err;
141 } 512
142 513 if (error)
143 NSString destinationOfSymbolicLinkAtPath (NSString path, NSError** error) 514 err = new objc_object;
144 { 515
145 return invokeObjcSelf!(NSString, "destinationOfSymbolicLinkAtPath:error:", NSString, NSError**)(path, error); 516 NSArray result = invokeObjcSelf!(NSArray, "contentsOfDirectoryAtPath:error:", NSString, id*)(path, &err);
146 } 517
147 518 if (err)
148 bool copyItemAtPath (NSString srcPath, NSString dstPath, NSError** error) 519 error = new NSError(err);
149 { 520
150 return invokeObjcSelf!(bool, "copyItemAtPath:toPath:error:", NSString, NSString, NSError**)(srcPath, dstPath, error); 521 return result;
151 } 522 }
152 523
153 bool moveItemAtPath (NSString srcPath, NSString dstPath, NSError** error) 524 NSArray subpathsOfDirectoryAtPath (NSString path, ref NSError error)
154 { 525 {
155 return invokeObjcSelf!(bool, "moveItemAtPath:toPath:error:", NSString, NSString, NSError**)(srcPath, dstPath, error); 526 id err;
156 } 527
157 528 if (error)
158 bool linkItemAtPath (NSString srcPath, NSString dstPath, NSError** error) 529 err = new objc_object;
159 { 530
160 return invokeObjcSelf!(bool, "linkItemAtPath:toPath:error:", NSString, NSString, NSError**)(srcPath, dstPath, error); 531 NSArray result = invokeObjcSelf!(NSArray, "subpathsOfDirectoryAtPath:error:", NSString, id*)(path, &err);
161 } 532
162 533 if (err)
163 bool removeItemAtPath (NSString path, NSError** error) 534 error = new NSError(err);
164 { 535
165 return invokeObjcSelf!(bool, "removeItemAtPath:error:", NSString, NSError**)(path, error); 536 return result;
537 }
538
539 NSDictionary attributesOfItemAtPath (NSString path, ref NSError error)
540 {
541 id err;
542
543 if (error)
544 err = new objc_object;
545
546 NSDictionary result = invokeObjcSelf!(NSDictionary, "attributesOfItemAtPath:error:", NSString, id*)(path, &err);
547
548 if (err)
549 error = new NSError(err);
550
551 return result;
552 }
553
554 NSDictionary attributesOfFileSystemForPath (NSString path, ref NSError error)
555 {
556 id err;
557
558 if (error)
559 err = new objc_object;
560
561 NSDictionary result = invokeObjcSelf!(NSDictionary, "attributesOfFileSystemForPath:error:", NSString, id*)(path, &err);
562
563 if (err)
564 error = new NSError(err);
565
566 return result;
567 }
568
569 bool createSymbolicLinkAtPath (NSString path, NSString destPath, ref NSError error)
570 {
571 id err;
572
573 if (error)
574 err = new objc_object;
575
576 bool result = invokeObjcSelf!(bool, "createSymbolicLinkAtPath:withDestinationPath:error:", NSString, NSString, id*)(path, destPath, &err);
577
578 if (err)
579 error = new NSError(err);
580
581 return result;
582 }
583
584 NSString destinationOfSymbolicLinkAtPath (NSString path, ref NSError error)
585 {
586 id err;
587
588 if (error)
589 err = new objc_object;
590
591 NSString result = invokeObjcSelf!(NSString, "destinationOfSymbolicLinkAtPath:error:", NSString, id*)(path, &err);
592
593 if (err)
594 error = new NSError(err);
595
596 return result;
597 }
598
599 bool copyItemAtPath (NSString srcPath, NSString dstPath, ref NSError error)
600 {
601 id err;
602
603 if (error)
604 err = new objc_object;
605
606 bool result = invokeObjcSelf!(bool, "copyItemAtPath:toPath:error:", NSString, NSString, id*)(srcPath, dstPath, &err);
607
608 if (err)
609 error = new NSError(err);
610
611 return result;
612 }
613
614 bool moveItemAtPath (NSString srcPath, NSString dstPath, ref NSError error)
615 {
616 id err;
617
618 if (error)
619 err = new objc_object;
620
621 bool result = invokeObjcSelf!(bool, "moveItemAtPath:toPath:error:", NSString, NSString, id*)(srcPath, dstPath, &err);
622
623 if (err)
624 error = new NSError(err);
625
626 return result;
627 }
628
629 bool linkItemAtPath (NSString srcPath, NSString dstPath, ref NSError error)
630 {
631 id err;
632
633 if (error)
634 err = new objc_object;
635
636 bool result = invokeObjcSelf!(bool, "linkItemAtPath:toPath:error:", NSString, NSString, id*)(srcPath, dstPath, &err);
637
638 if (err)
639 error = new NSError(err);
640
641 return result;
642 }
643
644 bool removeItemAtPath (NSString path, ref NSError error)
645 {
646 id err;
647
648 if (error)
649 err = new objc_object;
650
651 bool result = invokeObjcSelf!(bool, "removeItemAtPath:error:", NSString, id*)(path, &err);
652
653 if (err)
654 error = new NSError(err);
655
656 return result;
166 } 657 }
167 658
168 NSDictionary fileAttributesAtPath (NSString path, bool yorn) 659 NSDictionary fileAttributesAtPath (NSString path, bool yorn)
169 { 660 {
170 return invokeObjcSelf!(NSDictionary, "fileAttributesAtPath:traverseLink:", NSString, bool)(path, yorn); 661 return invokeObjcSelf!(NSDictionary, "fileAttributesAtPath:traverseLink:", NSString, bool)(path, yorn);
233 bool fileExistsAtPath (NSString path) 724 bool fileExistsAtPath (NSString path)
234 { 725 {
235 return invokeObjcSelf!(bool, "fileExistsAtPath:", NSString)(path); 726 return invokeObjcSelf!(bool, "fileExistsAtPath:", NSString)(path);
236 } 727 }
237 728
238 bool fileExistsAtPath (NSString path, bool* isDirectory) 729 bool fileExistsAtPath (NSString path, out bool isDirectory)
239 { 730 {
240 return invokeObjcSelf!(bool, "fileExistsAtPath:isDirectory:", NSString, bool*)(path, isDirectory); 731 return invokeObjcSelf!(bool, "fileExistsAtPath:isDirectory:", NSString, bool*)(path, &isDirectory);
241 } 732 }
242 733
243 bool isReadableFileAtPath (NSString path) 734 bool isReadableFileAtPath (NSString path)
244 { 735 {
245 return invokeObjcSelf!(bool, "isReadableFileAtPath:", NSString)(path); 736 return invokeObjcSelf!(bool, "isReadableFileAtPath:", NSString)(path);
306 } 797 }
307 } 798 }
308 799
309 class NSDirectoryEnumerator : NSEnumerator 800 class NSDirectoryEnumerator : NSEnumerator
310 { 801 {
311 mixin ObjcWrap; 802 mixin (ObjcWrap);
803
804 this ()
805 {
806 super(typeof(this).alloc.init.objcObject);
807 }
808
809 typeof(this) init ()
810 {
811 return invokeObjcSelf!(typeof(this), "init");
812 }
312 813
313 NSDictionary fileAttributes () 814 NSDictionary fileAttributes ()
314 { 815 {
315 return invokeObjcSelf!(NSDictionary, "fileAttributes"); 816 return invokeObjcSelf!(NSDictionary, "fileAttributes");
316 } 817 }
323 void skipDescendents () 824 void skipDescendents ()
324 { 825 {
325 return invokeObjcSelf!(void, "skipDescendents"); 826 return invokeObjcSelf!(void, "skipDescendents");
326 } 827 }
327 } 828 }
328
329 template TNSFileManagerFileOperationAdditions ()
330 {
331 bool fileManager (NSFileManager fileManager, NSString srcPath, NSString dstPath);
332 bool fileManager (NSFileManager fileManager, NSError error, NSString srcPath, NSString dstPath);
333 bool fileManager (NSFileManager fileManager, NSString srcPath, NSString dstPath);
334 bool fileManager (NSFileManager fileManager, NSError error, NSString srcPath, NSString dstPath);
335 bool fileManager (NSFileManager fileManager, NSString srcPath, NSString dstPath);
336 bool fileManager (NSFileManager fileManager, NSError error, NSString srcPath, NSString dstPath);
337 bool fileManager (NSFileManager fileManager, NSString path);
338 bool fileManager (NSFileManager fileManager, NSError error, NSString path);
339 }
340
341 template TNSCopyLinkMoveHandler ()
342 {
343 bool fileManager (NSFileManager fm, NSDictionary errorInfo);
344 void fileManager (NSFileManager fm, NSString path);
345 }
346
347 template TNSFileAttributes ()
348 {
349 ulong fileSize ()
350 {
351 return invokeObjcSelf!(ulong, "fileSize");
352 }
353
354 NSDate fileModificationDate ()
355 {
356 return invokeObjcSelf!(NSDate, "fileModificationDate");
357 }
358
359 NSString fileType ()
360 {
361 return invokeObjcSelf!(NSString, "fileType");
362 }
363
364 NSUInteger filePosixPermissions ()
365 {
366 return invokeObjcSelf!(NSUInteger, "filePosixPermissions");
367 }
368
369 NSString fileOwnerAccountName ()
370 {
371 return invokeObjcSelf!(NSString, "fileOwnerAccountName");
372 }
373
374 NSString fileGroupOwnerAccountName ()
375 {
376 return invokeObjcSelf!(NSString, "fileGroupOwnerAccountName");
377 }
378
379 NSInteger fileSystemNumber ()
380 {
381 return invokeObjcSelf!(NSInteger, "fileSystemNumber");
382 }
383
384 NSUInteger fileSystemFileNumber ()
385 {
386 return invokeObjcSelf!(NSUInteger, "fileSystemFileNumber");
387 }
388
389 bool fileExtensionHidden ()
390 {
391 return invokeObjcSelf!(bool, "fileExtensionHidden");
392 }
393
394 uint fileHFSCreatorCode ()
395 {
396 return invokeObjcSelf!(uint, "fileHFSCreatorCode");
397 }
398
399 uint fileHFSTypeCode ()
400 {
401 return invokeObjcSelf!(uint, "fileHFSTypeCode");
402 }
403
404 bool fileIsImmutable ()
405 {
406 return invokeObjcSelf!(bool, "fileIsImmutable");
407 }
408
409 bool fileIsAppendOnly ()
410 {
411 return invokeObjcSelf!(bool, "fileIsAppendOnly");
412 }
413
414 NSDate fileCreationDate ()
415 {
416 return invokeObjcSelf!(NSDate, "fileCreationDate");
417 }
418
419 NSNumber fileOwnerAccountID ()
420 {
421 return invokeObjcSelf!(NSNumber, "fileOwnerAccountID");
422 }
423
424 NSNumber fileGroupOwnerAccountID ()
425 {
426 return invokeObjcSelf!(NSNumber, "fileGroupOwnerAccountID");
427 }
428 }
429