Mercurial > projects > dwt-mac
comparison dwt/internal/cocoa/NSFileManager.d @ 45:d8635bb48c7c
Merge with SWT 3.5
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Mon, 01 Dec 2008 17:07:00 +0100 |
parents | f565d3a95c0a |
children | e1c48e37e0f5 |
comparison
equal
deleted
inserted
replaced
44:ca5e494f2bbf | 45:d8635bb48c7c |
---|---|
1 /******************************************************************************* | 1 /******************************************************************************* |
2 * Copyright (c) 2007 IBM Corporation and others. | 2 * Copyright (c) 2000, 2008 IBM Corporation and others. |
3 * All rights reserved. This program and the accompanying materials | 3 * All rights reserved. This program and the accompanying materials |
4 * are made available under the terms of the Eclipse Public License v1.0 | 4 * are made available under the terms of the Eclipse Public License v1.0 |
5 * which accompanies this distribution, and is available at | 5 * which accompanies this distribution, and is available at |
6 * http://www.eclipse.org/legal/epl-v10.html | 6 * http://www.eclipse.org/legal/epl-v10.html |
7 * | 7 * |
8 * Contributors: | 8 * Contributors: |
9 * IBM Corporation - initial API and implementation | 9 * IBM Corporation - initial API and implementation |
10 * | 10 * |
11 * Port to the D programming language: | 11 * Port to the D programming language: |
12 * Jacob Carlborg <jacob.carlborg@gmail.com> | 12 * Jacob Carlborg <doob@me.com> |
13 *******************************************************************************/ | 13 *******************************************************************************/ |
14 module dwt.internal.cocoa.NSFileManager; | 14 module dwt.internal.cocoa.NSFileManager; |
15 | 15 |
16 import dwt.internal.cocoa.id; | 16 import dwt.dwthelper.utils; |
17 import dwt.internal.cocoa.NSArray; | 17 import cocoa = dwt.internal.cocoa.id; |
18 import dwt.internal.cocoa.NSData; | 18 import dwt.internal.cocoa.NSData; |
19 import dwt.internal.cocoa.NSDictionary; | 19 import dwt.internal.cocoa.NSDictionary; |
20 import dwt.internal.cocoa.NSDirectoryEnumerator; | 20 import dwt.internal.cocoa.NSDirectoryEnumerator; |
21 import dwt.internal.cocoa.NSInteger; | 21 import dwt.internal.cocoa.NSError; |
22 import dwt.internal.cocoa.NSObject; | |
22 import dwt.internal.cocoa.NSString; | 23 import dwt.internal.cocoa.NSString; |
23 import dwt.internal.cocoa.NSObject; | |
24 import dwt.internal.cocoa.OS; | 24 import dwt.internal.cocoa.OS; |
25 import objc = dwt.internal.objc.runtime; | 25 import objc = dwt.internal.objc.runtime; |
26 | 26 |
27 public class NSFileManager : NSObject | 27 public class NSFileManager : NSObject { |
28 { | |
29 | 28 |
30 public this () | 29 public this() { |
31 { | 30 super(); |
32 super(); | 31 } |
33 } | |
34 | 32 |
35 public this (objc.id id) | 33 public this(objc.id id) { |
36 { | 34 super(id); |
37 super(id); | 35 } |
38 } | |
39 | 36 |
40 public NSDictionary attributesOfFileSystemForPath (NSString path, objc.id** error) | 37 public this(cocoa.id id) { |
41 { | 38 super(id); |
42 objc.id result = OS.objc_msgSend(this.id_, OS.sel_attributesOfFileSystemForPath_1error_1, path !is null ? path.id_ : null, error); | 39 } |
43 return result !is null ? new NSDictionary(result) : null; | |
44 } | |
45 | 40 |
46 public NSDictionary attributesOfItemAtPath (NSString path, objc.id** error) | 41 public bool createFileAtPath(NSString path, NSData data, NSDictionary attr) { |
47 { | 42 return OS.objc_msgSend_bool(this.id, OS.sel_createFileAtPath_contents_attributes_, path !is null ? path.id : null, data !is null ? data.id : null, attr !is null ? attr.id : null); |
48 objc.id result = OS.objc_msgSend(this.id_, OS.sel_attributesOfItemAtPath_1error_1, path !is null ? path.id_ : null, error); | 43 } |
49 return result !is null ? new NSDictionary(result) : null; | |
50 } | |
51 | 44 |
52 public bool changeCurrentDirectoryPath (NSString path) | 45 public static NSFileManager defaultManager() { |
53 { | 46 objc.id result = OS.objc_msgSend(OS.class_NSFileManager, OS.sel_defaultManager); |
54 return OS.objc_msgSend(this.id_, OS.sel_changeCurrentDirectoryPath_1, path !is null ? path.id_ : null) !is null; | 47 return result !is null ? new NSFileManager(result) : null; |
55 } | 48 } |
56 | 49 |
57 public bool changeFileAttributes (NSDictionary attributes, NSString path) | 50 public NSDirectoryEnumerator enumeratorAtPath(NSString path) { |
58 { | 51 objc.id result = OS.objc_msgSend(this.id, OS.sel_enumeratorAtPath_, path !is null ? path.id : null); |
59 return OS.objc_msgSend(this.id_, OS.sel_changeFileAttributes_1atPath_1, attributes !is null ? attributes.id_ : null, | 52 return result !is null ? new NSDirectoryEnumerator(result) : null; |
60 path !is null ? path.id_ : null) !is null; | 53 } |
61 } | |
62 | 54 |
63 public NSArray componentsToDisplayForPath (NSString path) | 55 public bool removeItemAtPath(NSString path, ref NSError error) { |
64 { | 56 return OS.objc_msgSend_bool(this.id, OS.sel_removeItemAtPath_error_, path !is null ? path.id : null, error !is null ? &error.id : null); |
65 objc.id result = OS.objc_msgSend(this.id_, OS.sel_componentsToDisplayForPath_1, path !is null ? path.id_ : null); | 57 } |
66 return result !is null ? new NSArray(result) : null; | |
67 } | |
68 | |
69 public NSData contentsAtPath (NSString path) | |
70 { | |
71 objc.id result = OS.objc_msgSend(this.id_, OS.sel_contentsAtPath_1, path !is null ? path.id_ : null); | |
72 return result !is null ? new NSData(result) : null; | |
73 } | |
74 | |
75 public bool contentsEqualAtPath (NSString path1, NSString path2) | |
76 { | |
77 return OS.objc_msgSend(this.id_, OS.sel_contentsEqualAtPath_1andPath_1, path1 !is null ? path1.id_ : null, path2 !is null ? path2.id_ : null) !is null; | |
78 } | |
79 | |
80 public NSArray contentsOfDirectoryAtPath (NSString path, objc.id** error) | |
81 { | |
82 objc.id result = OS.objc_msgSend(this.id_, OS.sel_contentsOfDirectoryAtPath_1error_1, path !is null ? path.id_ : null, error); | |
83 return result !is null ? new NSArray(result) : null; | |
84 } | |
85 | |
86 public bool copyItemAtPath (NSString srcPath, NSString dstPath, objc.id** error) | |
87 { | |
88 return OS.objc_msgSend(this.id_, OS.sel_copyItemAtPath_1toPath_1error_1, srcPath !is null ? srcPath.id_ : null, | |
89 dstPath !is null ? dstPath.id_ : null, error) !is null; | |
90 } | |
91 | |
92 public bool copyPath (NSString src, NSString dest, id handler) | |
93 { | |
94 return OS.objc_msgSend(this.id_, OS.sel_copyPath_1toPath_1handler_1, src !is null ? src.id_ : null, dest !is null ? dest.id_ : null, | |
95 handler !is null ? handler.id_ : null) !is null; | |
96 } | |
97 | |
98 public bool createDirectoryAtPath_attributes_ (NSString path, NSDictionary attributes) | |
99 { | |
100 return OS.objc_msgSend(this.id_, OS.sel_createDirectoryAtPath_1attributes_1, path !is null ? path.id_ : null, | |
101 attributes !is null ? attributes.id_ : null) !is null; | |
102 } | |
103 | |
104 public bool createDirectoryAtPath_withIntermediateDirectories_attributes_error_ (NSString path, bool createIntermediates, | |
105 NSDictionary attributes, objc.id** error) | |
106 { | |
107 return OS.objc_msgSend(this.id_, OS.sel_createDirectoryAtPath_1withIntermediateDirectories_1attributes_1error_1, | |
108 path !is null ? path.id_ : null, createIntermediates, attributes !is null ? attributes.id_ : null, error) !is null; | |
109 } | |
110 | |
111 public bool createFileAtPath (NSString path, NSData data, NSDictionary attr) | |
112 { | |
113 return OS.objc_msgSend(this.id_, OS.sel_createFileAtPath_1contents_1attributes_1, path !is null ? path.id_ : null, | |
114 data !is null ? data.id_ : null, attr !is null ? attr.id_ : null) !is null; | |
115 } | |
116 | |
117 public bool createSymbolicLinkAtPath_pathContent_ (NSString path, NSString otherpath) | |
118 { | |
119 return OS.objc_msgSend(this.id_, OS.sel_createSymbolicLinkAtPath_1pathContent_1, path !is null ? path.id_ : null, | |
120 otherpath !is null ? otherpath.id_ : null) !is null; | |
121 } | |
122 | |
123 public bool createSymbolicLinkAtPath_withDestinationPath_error_ (NSString path, NSString destPath, objc.id** error) | |
124 { | |
125 return OS.objc_msgSend(this.id_, OS.sel_createSymbolicLinkAtPath_1withDestinationPath_1error_1, path !is null ? path.id_ : null, | |
126 destPath !is null ? destPath.id_ : null, error) !is null; | |
127 } | |
128 | |
129 public NSString currentDirectoryPath () | |
130 { | |
131 objc.id result = OS.objc_msgSend(this.id_, OS.sel_currentDirectoryPath); | |
132 return result !is null ? new NSString(result) : null; | |
133 } | |
134 | |
135 public static NSFileManager defaultManager () | |
136 { | |
137 objc.id result = OS.objc_msgSend(OS.class_NSFileManager, OS.sel_defaultManager); | |
138 return result !is null ? new NSFileManager(result) : null; | |
139 } | |
140 | |
141 public id delegatee () | |
142 { | |
143 objc.id result = OS.objc_msgSend(this.id_, OS.sel_delegate); | |
144 return result !is null ? new id(result) : null; | |
145 } | |
146 | |
147 public NSString destinationOfSymbolicLinkAtPath (NSString path, objc.id** error) | |
148 { | |
149 objc.id result = OS.objc_msgSend(this.id_, OS.sel_destinationOfSymbolicLinkAtPath_1error_1, path !is null ? path.id_ : null, error); | |
150 return result !is null ? new NSString(result) : null; | |
151 } | |
152 | |
153 public NSArray directoryContentsAtPath (NSString path) | |
154 { | |
155 objc.id result = OS.objc_msgSend(this.id_, OS.sel_directoryContentsAtPath_1, path !is null ? path.id_ : null); | |
156 return result !is null ? new NSArray(result) : null; | |
157 } | |
158 | |
159 public NSString displayNameAtPath (NSString path) | |
160 { | |
161 objc.id result = OS.objc_msgSend(this.id_, OS.sel_displayNameAtPath_1, path !is null ? path.id_ : null); | |
162 return result !is null ? new NSString(result) : null; | |
163 } | |
164 | |
165 public NSDirectoryEnumerator enumeratorAtPath (NSString path) | |
166 { | |
167 objc.id result = OS.objc_msgSend(this.id_, OS.sel_enumeratorAtPath_1, path !is null ? path.id_ : null); | |
168 return result !is null ? new NSDirectoryEnumerator(result) : null; | |
169 } | |
170 | |
171 public NSDictionary fileAttributesAtPath (NSString path, bool yorn) | |
172 { | |
173 objc.id result = OS.objc_msgSend(this.id_, OS.sel_fileAttributesAtPath_1traverseLink_1, path !is null ? path.id_ : null, yorn); | |
174 return result !is null ? new NSDictionary(result) : null; | |
175 } | |
176 | |
177 public bool fileExistsAtPath_ (NSString path) | |
178 { | |
179 return OS.objc_msgSend(this.id_, OS.sel_fileExistsAtPath_1, path !is null ? path.id_ : null) !is null; | |
180 } | |
181 | |
182 public bool fileExistsAtPath_isDirectory_ (NSString path, bool* isDirectory) | |
183 { | |
184 return OS.objc_msgSend(this.id_, OS.sel_fileExistsAtPath_1isDirectory_1, path !is null ? path.id_ : null, isDirectory) !is null; | |
185 } | |
186 | |
187 public NSDictionary fileSystemAttributesAtPath (NSString path) | |
188 { | |
189 objc.id result = OS.objc_msgSend(this.id_, OS.sel_fileSystemAttributesAtPath_1, path !is null ? path.id_ : null); | |
190 return result !is null ? new NSDictionary(result) : null; | |
191 } | |
192 | |
193 public /*const*/char* fileSystemRepresentationWithPath (NSString path) | |
194 { | |
195 return cast(/*const*/char*) OS.objc_msgSend(this.id_, OS.sel_fileSystemRepresentationWithPath_1, path !is null ? path.id_ : null); | |
196 } | |
197 | |
198 public bool isDeletableFileAtPath (NSString path) | |
199 { | |
200 return OS.objc_msgSend(this.id_, OS.sel_isDeletableFileAtPath_1, path !is null ? path.id_ : null) !is null; | |
201 } | |
202 | |
203 public bool isExecutableFileAtPath (NSString path) | |
204 { | |
205 return OS.objc_msgSend(this.id_, OS.sel_isExecutableFileAtPath_1, path !is null ? path.id_ : null) !is null; | |
206 } | |
207 | |
208 public bool isReadableFileAtPath (NSString path) | |
209 { | |
210 return OS.objc_msgSend(this.id_, OS.sel_isReadableFileAtPath_1, path !is null ? path.id_ : null) !is null; | |
211 } | |
212 | |
213 public bool isWritableFileAtPath (NSString path) | |
214 { | |
215 return OS.objc_msgSend(this.id_, OS.sel_isWritableFileAtPath_1, path !is null ? path.id_ : null) !is null; | |
216 } | |
217 | |
218 public bool linkItemAtPath (NSString srcPath, NSString dstPath, objc.id** error) | |
219 { | |
220 return OS.objc_msgSend(this.id_, OS.sel_linkItemAtPath_1toPath_1error_1, srcPath !is null ? srcPath.id_ : null, | |
221 dstPath !is null ? dstPath.id_ : null, error) !is null; | |
222 } | |
223 | |
224 public bool linkPath (NSString src, NSString dest, id handler) | |
225 { | |
226 return OS.objc_msgSend(this.id_, OS.sel_linkPath_1toPath_1handler_1, src !is null ? src.id_ : null, dest !is null ? dest.id_ : null, | |
227 handler !is null ? handler.id_ : null) !is null; | |
228 } | |
229 | |
230 public bool moveItemAtPath (NSString srcPath, NSString dstPath, objc.id** error) | |
231 { | |
232 return OS.objc_msgSend(this.id_, OS.sel_moveItemAtPath_1toPath_1error_1, srcPath !is null ? srcPath.id_ : null, | |
233 dstPath !is null ? dstPath.id_ : null, error) !is null; | |
234 } | |
235 | |
236 public bool movePath (NSString src, NSString dest, id handler) | |
237 { | |
238 return OS.objc_msgSend(this.id_, OS.sel_movePath_1toPath_1handler_1, src !is null ? src.id_ : null, dest !is null ? dest.id_ : null, | |
239 handler !is null ? handler.id_ : null) !is null; | |
240 } | |
241 | |
242 public NSString pathContentOfSymbolicLinkAtPath (NSString path) | |
243 { | |
244 objc.id result = OS.objc_msgSend(this.id_, OS.sel_pathContentOfSymbolicLinkAtPath_1, path !is null ? path.id_ : null); | |
245 return result !is null ? new NSString(result) : null; | |
246 } | |
247 | |
248 public bool removeFileAtPath (NSString path, id handler) | |
249 { | |
250 return OS.objc_msgSend(this.id_, OS.sel_removeFileAtPath_1handler_1, path !is null ? path.id_ : null, handler !is null ? handler.id_ : null) !is null; | |
251 } | |
252 | |
253 public bool removeItemAtPath (NSString path, objc.id** error) | |
254 { | |
255 return OS.objc_msgSend(this.id_, OS.sel_removeItemAtPath_1error_1, path !is null ? path.id_ : null, error) !is null; | |
256 } | |
257 | |
258 public bool setAttributes (NSDictionary attributes, NSString path, objc.id** error) | |
259 { | |
260 return OS.objc_msgSend(this.id_, OS.sel_setAttributes_1ofItemAtPath_1error_1, attributes !is null ? attributes.id_ : null, | |
261 path !is null ? path.id_ : null, error) !is null; | |
262 } | |
263 | |
264 public void setDelegate (id delegatee) | |
265 { | |
266 OS.objc_msgSend(this.id_, OS.sel_setDelegate_1, delegatee !is null ? delegatee.id_ : null); | |
267 } | |
268 | |
269 public NSString stringWithFileSystemRepresentation (/*const*/char* str, NSUInteger len) | |
270 { | |
271 objc.id result = OS.objc_msgSend(this.id_, OS.sel_stringWithFileSystemRepresentation_1length_1, str, len); | |
272 return result !is null ? new NSString(result) : null; | |
273 } | |
274 | |
275 public NSArray subpathsAtPath (NSString path) | |
276 { | |
277 objc.id result = OS.objc_msgSend(this.id_, OS.sel_subpathsAtPath_1, path !is null ? path.id_ : null); | |
278 return result !is null ? new NSArray(result) : null; | |
279 } | |
280 | |
281 public NSArray subpathsOfDirectoryAtPath (NSString path, objc.id** error) | |
282 { | |
283 objc.id result = OS.objc_msgSend(this.id_, OS.sel_subpathsOfDirectoryAtPath_1error_1, path !is null ? path.id_ : null, error); | |
284 return result !is null ? new NSArray(result) : null; | |
285 } | |
286 | 58 |
287 } | 59 } |