comparison dwt/internal/cocoa/NSFileManager.d @ 0:380af2bdd8e5

Upload of whole dwt tree
author Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
date Sat, 09 Aug 2008 17:00:02 +0200
parents
children 8b48be5454ce
comparison
equal deleted inserted replaced
-1:000000000000 0:380af2bdd8e5
1 /*******************************************************************************
2 * Copyright (c) 2007 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * IBM Corporation - initial API and implementation
10 *
11 * Port to the D Programming language:
12 * Jacob Carlborg <jacob.carlborg@gmail.com>
13 *******************************************************************************/
14 module dwt.internal.cocoa.NSFileManager;
15
16 import dwt.internal.cocoa.id;
17 import dwt.internal.cocoa.NSArray;
18 import dwt.internal.cocoa.NSData;
19 import dwt.internal.cocoa.NSDictionary;
20 import dwt.internal.cocoa.NSDirectoryEnumerator;
21 import dwt.internal.cocoa.NSInteger;
22 import dwt.internal.cocoa.NSString;
23 import dwt.internal.cocoa.NSObject;
24 import dwt.internal.cocoa.OS;
25 import objc = dwt.internal.objc.runtime;
26
27 public class NSFileManager : NSObject
28 {
29
30 public this ()
31 {
32 super();
33 }
34
35 public this (objc.id id)
36 {
37 super(id);
38 }
39
40 public NSDictionary attributesOfFileSystemForPath (NSString path, objc.id** error)
41 {
42 objc.id result = OS.objc_msgSend(this.id, OS.sel_attributesOfFileSystemForPath_1error_1, path !is null ? path.id : null, error);
43 return result !is null ? new NSDictionary(result) : null;
44 }
45
46 public NSDictionary attributesOfItemAtPath (NSString path, objc.id** error)
47 {
48 objc.id result = OS.objc_msgSend(this.id, OS.sel_attributesOfItemAtPath_1error_1, path !is null ? path.id : null, error);
49 return result !is null ? new NSDictionary(result) : null;
50 }
51
52 public bool changeCurrentDirectoryPath (NSString path)
53 {
54 return OS.objc_msgSend(this.id, OS.sel_changeCurrentDirectoryPath_1, path !is null ? path.id : null) !is null;
55 }
56
57 public bool changeFileAttributes (NSDictionary attributes, NSString path)
58 {
59 return OS.objc_msgSend(this.id, OS.sel_changeFileAttributes_1atPath_1, attributes !is null ? attributes.id : null,
60 path !is null ? path.id : null) !is null;
61 }
62
63 public NSArray componentsToDisplayForPath (NSString path)
64 {
65 objc.id result = OS.objc_msgSend(this.id, OS.sel_componentsToDisplayForPath_1, path !is null ? path.id : null);
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 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
287 }