Mercurial > projects > dstep
annotate dstep/foundation/NSFileManager.d @ 15:7ff919f595d5
Added the Foundation framework, again
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Mon, 03 Aug 2009 15:31:48 +0200 |
parents | 89f3c3ef1fd2 |
children | 19885b43130e |
rev | line source |
---|---|
14 | 1 /** |
2 * Copyright: Copyright (c) 2009 Jacob Carlborg. | |
3 * Authors: Jacob Carlborg | |
4 * Version: Initial created: Aug 3, 2009 | |
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) | |
6 */ | |
7 module dstep.foundation.NSFileManager; | |
8 | |
9 import dstep.corefoundation.CFBase; | |
10 import dstep.foundation.NSArray; | |
11 import dstep.foundation.NSData; | |
12 import dstep.foundation.NSDate; | |
13 import dstep.foundation.NSDictionary; | |
14 import dstep.foundation.NSDirectoryEnumerator; | |
15 import dstep.foundation.NSEnumerator; | |
16 import dstep.foundation.NSError; | |
17 import dstep.foundation.NSNumber; | |
18 import dstep.foundation.NSObject; | |
19 import dstep.objc.bridge.Bridge; | |
20 import dstep.objc.objc : id; | |
21 | |
22 import bindings = dstep.foundation.NSFileManager_bindings; | |
23 | |
24 const NSString NSFileType; | |
25 const NSString NSFileTypeDirectory; | |
26 const NSString NSFileTypeRegular; | |
27 const NSString NSFileTypeSymbolicLink; | |
28 const NSString NSFileTypeSocket; | |
29 const NSString NSFileTypeCharacterSpecial; | |
30 const NSString NSFileTypeBlockSpecial; | |
31 const NSString NSFileTypeUnknown; | |
32 const NSString NSFileSize; | |
33 const NSString NSFileModificationDate; | |
34 const NSString NSFileReferenceCount; | |
35 const NSString NSFileDeviceIdentifier; | |
36 const NSString NSFileOwnerAccountName; | |
37 const NSString NSFileGroupOwnerAccountName; | |
38 const NSString NSFilePosixPermissions; | |
39 const NSString NSFileSystemNumber; | |
40 const NSString NSFileSystemFileNumber; | |
41 const NSString NSFileExtensionHidden; | |
42 const NSString NSFileHFSCreatorCode; | |
43 const NSString NSFileHFSTypeCode; | |
44 const NSString NSFileImmutable; | |
45 const NSString NSFileAppendOnly; | |
46 const NSString NSFileCreationDate; | |
47 const NSString NSFileOwnerAccountID; | |
48 const NSString NSFileGroupOwnerAccountID; | |
49 const NSString NSFileBusy; | |
50 const NSString NSFileSystemSize; | |
51 const NSString NSFileSystemFreeSize; | |
52 const NSString NSFileSystemNodes; | |
53 const NSString NSFileSystemFreeNodes; | |
54 | |
55 static this () | |
56 { | |
57 NSFileType = new NSString(bindings.NSFileType); | |
58 NSFileTypeDirectory = new NSString(bindings.NSFileTypeDirectory); | |
59 NSFileTypeRegular = new NSString(bindings.NSFileTypeRegular); | |
60 NSFileTypeSymbolicLink = new NSString(bindings.NSFileTypeSymbolicLink); | |
61 NSFileTypeSocket = new NSString(bindings.NSFileTypeSocket); | |
62 NSFileTypeCharacterSpecial = new NSString(bindings.NSFileTypeCharacterSpecial); | |
63 NSFileTypeBlockSpecial = new NSString(bindings.NSFileTypeBlockSpecial); | |
64 NSFileTypeUnknown = new NSString(bindings.NSFileTypeUnknown); | |
65 NSFileSize = new NSString(bindings.NSFileSize); | |
66 NSFileModificationDate = new NSString(bindings.NSFileModificationDate); | |
67 NSFileReferenceCount = new NSString(bindings.NSFileReferenceCount); | |
68 NSFileDeviceIdentifier = new NSString(bindings.NSFileDeviceIdentifier); | |
69 NSFileOwnerAccountName = new NSString(bindings.NSFileOwnerAccountName); | |
70 NSFileGroupOwnerAccountName = new NSString(bindings.NSFileGroupOwnerAccountName); | |
71 NSFilePosixPermissions = new NSString(bindings.NSFilePosixPermissions); | |
72 NSFileSystemNumber = new NSString(bindings.NSFileSystemNumber); | |
73 NSFileSystemFileNumber = new NSString(bindings.NSFileSystemFileNumber); | |
74 NSFileExtensionHidden = new NSString(bindings.NSFileExtensionHidden); | |
75 NSFileHFSCreatorCode = new NSString(bindings.NSFileHFSCreatorCode); | |
76 NSFileHFSTypeCode = new NSString(bindings.NSFileHFSTypeCode); | |
77 NSFileImmutable = new NSString(bindings.NSFileImmutable); | |
78 NSFileAppendOnly = new NSString(bindings.NSFileAppendOnly); | |
79 NSFileCreationDate = new NSString(bindings.NSFileCreationDate); | |
80 NSFileOwnerAccountID = new NSString(bindings.NSFileOwnerAccountID); | |
81 NSFileGroupOwnerAccountID = new NSString(bindings.NSFileGroupOwnerAccountID); | |
82 NSFileBusy = new NSString(bindings.NSFileBusy); | |
83 NSFileSystemSize = new NSString(bindings.NSFileSystemSize); | |
84 NSFileSystemFreeSize = new NSString(bindings.NSFileSystemFreeSize); | |
85 NSFileSystemNodes = new NSString(bindings.NSFileSystemNodes); | |
86 NSFileSystemFreeNodes = new NSString(bindings.NSFileSystemFreeNodes); | |
87 } | |
88 | |
89 class NSFileManager : NSObject | |
90 { | |
91 mixin ObjcWrap; | |
92 | |
93 static NSFileManager defaultManager () | |
94 { | |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
95 return invokeObjcSelfClass!(NSFileManager, "defaultManager"); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
96 } |
14 | 97 |
98 void setDelegate (Object delegate_) | |
99 { | |
100 return invokeObjcSelf!(void, "setDelegate:", Object)(delegate_); | |
101 } | |
102 | |
103 Object delegate_ () | |
104 { | |
105 return invokeObjcSelf!(Object, "delegate"); | |
106 } | |
107 | |
108 bool setAttributes (NSDictionary attributes, NSString path, NSError** error) | |
109 { | |
110 return invokeObjcSelf!(bool, "setAttributes:ofItemAtPath:error:", NSDictionary, NSString, NSError**)(attributes, path, error); | |
111 } | |
112 | |
113 bool createDirectoryAtPath (NSString path, bool createIntermediates, NSDictionary attributes, NSError** error) | |
114 { | |
115 return invokeObjcSelf!(bool, "createDirectoryAtPath:withIntermediateDirectories:attributes:error:", NSString, bool, NSDictionary, NSError**)(path, createIntermediates, attributes, error); | |
116 } | |
117 | |
118 NSArray contentsOfDirectoryAtPath (NSString path, NSError** error) | |
119 { | |
120 return invokeObjcSelf!(NSArray, "contentsOfDirectoryAtPath:error:", NSString, NSError**)(path, error); | |
121 } | |
122 | |
123 NSArray subpathsOfDirectoryAtPath (NSString path, NSError** error) | |
124 { | |
125 return invokeObjcSelf!(NSArray, "subpathsOfDirectoryAtPath:error:", NSString, NSError**)(path, error); | |
126 } | |
127 | |
128 NSDictionary attributesOfItemAtPath (NSString path, NSError** error) | |
129 { | |
130 return invokeObjcSelf!(NSDictionary, "attributesOfItemAtPath:error:", NSString, NSError**)(path, error); | |
131 } | |
132 | |
133 NSDictionary attributesOfFileSystemForPath (NSString path, NSError** error) | |
134 { | |
135 return invokeObjcSelf!(NSDictionary, "attributesOfFileSystemForPath:error:", NSString, NSError**)(path, error); | |
136 } | |
137 | |
138 bool createSymbolicLinkAtPath (NSString path, NSString destPath, NSError** error) | |
139 { | |
140 return invokeObjcSelf!(bool, "createSymbolicLinkAtPath:withDestinationPath:error:", NSString, NSString, NSError**)(path, destPath, error); | |
141 } | |
142 | |
143 NSString destinationOfSymbolicLinkAtPath (NSString path, NSError** error) | |
144 { | |
145 return invokeObjcSelf!(NSString, "destinationOfSymbolicLinkAtPath:error:", NSString, NSError**)(path, error); | |
146 } | |
147 | |
148 bool copyItemAtPath (NSString srcPath, NSString dstPath, NSError** error) | |
149 { | |
150 return invokeObjcSelf!(bool, "copyItemAtPath:toPath:error:", NSString, NSString, NSError**)(srcPath, dstPath, error); | |
151 } | |
152 | |
153 bool moveItemAtPath (NSString srcPath, NSString dstPath, NSError** error) | |
154 { | |
155 return invokeObjcSelf!(bool, "moveItemAtPath:toPath:error:", NSString, NSString, NSError**)(srcPath, dstPath, error); | |
156 } | |
157 | |
158 bool linkItemAtPath (NSString srcPath, NSString dstPath, NSError** error) | |
159 { | |
160 return invokeObjcSelf!(bool, "linkItemAtPath:toPath:error:", NSString, NSString, NSError**)(srcPath, dstPath, error); | |
161 } | |
162 | |
163 bool removeItemAtPath (NSString path, NSError** error) | |
164 { | |
165 return invokeObjcSelf!(bool, "removeItemAtPath:error:", NSString, NSError**)(path, error); | |
166 } | |
167 | |
168 NSDictionary fileAttributesAtPath (NSString path, bool yorn) | |
169 { | |
170 return invokeObjcSelf!(NSDictionary, "fileAttributesAtPath:traverseLink:", NSString, bool)(path, yorn); | |
171 } | |
172 | |
173 bool changeFileAttributes (NSDictionary attributes, NSString path) | |
174 { | |
175 return invokeObjcSelf!(bool, "changeFileAttributes:atPath:", NSDictionary, NSString)(attributes, path); | |
176 } | |
177 | |
178 NSArray directoryContentsAtPath (NSString path) | |
179 { | |
180 return invokeObjcSelf!(NSArray, "directoryContentsAtPath:", NSString)(path); | |
181 } | |
182 | |
183 NSDictionary fileSystemAttributesAtPath (NSString path) | |
184 { | |
185 return invokeObjcSelf!(NSDictionary, "fileSystemAttributesAtPath:", NSString)(path); | |
186 } | |
187 | |
188 NSString pathContentOfSymbolicLinkAtPath (NSString path) | |
189 { | |
190 return invokeObjcSelf!(NSString, "pathContentOfSymbolicLinkAtPath:", NSString)(path); | |
191 } | |
192 | |
193 bool createSymbolicLinkAtPath (NSString path, NSString otherpath) | |
194 { | |
195 return invokeObjcSelf!(bool, "createSymbolicLinkAtPath:pathContent:", NSString, NSString)(path, otherpath); | |
196 } | |
197 | |
198 bool createDirectoryAtPath (NSString path, NSDictionary attributes) | |
199 { | |
200 return invokeObjcSelf!(bool, "createDirectoryAtPath:attributes:", NSString, NSDictionary)(path, attributes); | |
201 } | |
202 | |
203 bool linkPath (NSString src, NSString dest, Object handler) | |
204 { | |
205 return invokeObjcSelf!(bool, "linkPath:toPath:handler:", NSString, NSString, Object)(src, dest, handler); | |
206 } | |
207 | |
208 bool copyPath (NSString src, NSString dest, Object handler) | |
209 { | |
210 return invokeObjcSelf!(bool, "copyPath:toPath:handler:", NSString, NSString, Object)(src, dest, handler); | |
211 } | |
212 | |
213 bool movePath (NSString src, NSString dest, Object handler) | |
214 { | |
215 return invokeObjcSelf!(bool, "movePath:toPath:handler:", NSString, NSString, Object)(src, dest, handler); | |
216 } | |
217 | |
218 bool removeFileAtPath (NSString path, Object handler) | |
219 { | |
220 return invokeObjcSelf!(bool, "removeFileAtPath:handler:", NSString, Object)(path, handler); | |
221 } | |
222 | |
223 NSString currentDirectoryPath () | |
224 { | |
225 return invokeObjcSelf!(NSString, "currentDirectoryPath"); | |
226 } | |
227 | |
228 bool changeCurrentDirectoryPath (NSString path) | |
229 { | |
230 return invokeObjcSelf!(bool, "changeCurrentDirectoryPath:", NSString)(path); | |
231 } | |
232 | |
233 bool fileExistsAtPath (NSString path) | |
234 { | |
235 return invokeObjcSelf!(bool, "fileExistsAtPath:", NSString)(path); | |
236 } | |
237 | |
238 bool fileExistsAtPath (NSString path, bool* isDirectory) | |
239 { | |
240 return invokeObjcSelf!(bool, "fileExistsAtPath:isDirectory:", NSString, bool*)(path, isDirectory); | |
241 } | |
242 | |
243 bool isReadableFileAtPath (NSString path) | |
244 { | |
245 return invokeObjcSelf!(bool, "isReadableFileAtPath:", NSString)(path); | |
246 } | |
247 | |
248 bool isWritableFileAtPath (NSString path) | |
249 { | |
250 return invokeObjcSelf!(bool, "isWritableFileAtPath:", NSString)(path); | |
251 } | |
252 | |
253 bool isExecutableFileAtPath (NSString path) | |
254 { | |
255 return invokeObjcSelf!(bool, "isExecutableFileAtPath:", NSString)(path); | |
256 } | |
257 | |
258 bool isDeletableFileAtPath (NSString path) | |
259 { | |
260 return invokeObjcSelf!(bool, "isDeletableFileAtPath:", NSString)(path); | |
261 } | |
262 | |
263 bool contentsEqualAtPath (NSString path1, NSString path2) | |
264 { | |
265 return invokeObjcSelf!(bool, "contentsEqualAtPath:andPath:", NSString, NSString)(path1, path2); | |
266 } | |
267 | |
268 NSString displayNameAtPath (NSString path) | |
269 { | |
270 return invokeObjcSelf!(NSString, "displayNameAtPath:", NSString)(path); | |
271 } | |
272 | |
273 NSArray componentsToDisplayForPath (NSString path) | |
274 { | |
275 return invokeObjcSelf!(NSArray, "componentsToDisplayForPath:", NSString)(path); | |
276 } | |
277 | |
278 NSDirectoryEnumerator enumeratorAtPath (NSString path) | |
279 { | |
280 return invokeObjcSelf!(NSDirectoryEnumerator, "enumeratorAtPath:", NSString)(path); | |
281 } | |
282 | |
283 NSArray subpathsAtPath (NSString path) | |
284 { | |
285 return invokeObjcSelf!(NSArray, "subpathsAtPath:", NSString)(path); | |
286 } | |
287 | |
288 NSData contentsAtPath (NSString path) | |
289 { | |
290 return invokeObjcSelf!(NSData, "contentsAtPath:", NSString)(path); | |
291 } | |
292 | |
293 bool createFileAtPath (NSString path, NSData data, NSDictionary attr) | |
294 { | |
295 return invokeObjcSelf!(bool, "createFileAtPath:contents:attributes:", NSString, NSData, NSDictionary)(path, data, attr); | |
296 } | |
297 | |
298 char* fileSystemRepresentationWithPath (NSString path) | |
299 { | |
300 return invokeObjcSelf!(char*, "fileSystemRepresentationWithPath:", NSString)(path); | |
301 } | |
302 | |
303 NSString stringWithFileSystemRepresentation (char* str, NSUInteger len) | |
304 { | |
305 return invokeObjcSelf!(NSString, "stringWithFileSystemRepresentation:length:", char*, NSUInteger)(str, len); | |
306 } | |
307 } | |
308 | |
309 class NSDirectoryEnumerator : NSEnumerator | |
310 { | |
311 mixin ObjcWrap; | |
312 | |
313 NSDictionary fileAttributes () | |
314 { | |
315 return invokeObjcSelf!(NSDictionary, "fileAttributes"); | |
316 } | |
317 | |
318 NSDictionary directoryAttributes () | |
319 { | |
320 return invokeObjcSelf!(NSDictionary, "directoryAttributes"); | |
321 } | |
322 | |
323 void skipDescendents () | |
324 { | |
325 return invokeObjcSelf!(void, "skipDescendents"); | |
326 } | |
327 } | |
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 |