Mercurial > projects > dstep
annotate dstep/foundation/NSPathUtilities.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 | 89f3c3ef1fd2 |
children |
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.NSPathUtilities; | |
8 | |
9 import dstep.foundation.NSArray; | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
10 import dstep.foundation.NSObjCRuntime; |
14 | 11 import dstep.foundation.NSString; |
12 import dstep.objc.bridge.Bridge; | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
13 import dstep.objc.objc; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
14 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
15 import bindings = dstep.foundation.NSPathUtilities_bindings; |
14 | 16 |
17 alias NSUInteger NSSearchPathDirectory; | |
18 alias NSUInteger NSSearchPathDomainMask; | |
19 | |
20 enum | |
21 { | |
22 NSApplicationDirectory = 1, | |
23 NSDemoApplicationDirectory, | |
24 NSDeveloperApplicationDirectory, | |
25 NSAdminApplicationDirectory, | |
26 NSLibraryDirectory, | |
27 NSDeveloperDirectory, | |
28 NSUserDirectory, | |
29 NSDocumentationDirectory, | |
30 NSDocumentDirectory, | |
31 NSCoreServiceDirectory, | |
32 NSDesktopDirectory = 12, | |
33 NSCachesDirectory = 13, | |
34 NSApplicationSupportDirectory = 14, | |
35 NSDownloadsDirectory = 15, | |
36 NSAllApplicationsDirectory = 100, | |
37 NSAllLibrariesDirectory = 101 | |
38 } | |
39 | |
40 enum | |
41 { | |
42 NSUserDomainMask = 1, | |
43 NSLocalDomainMask = 2, | |
44 NSNetworkDomainMask = 4, | |
45 NSSystemDomainMask = 8, | |
46 NSAllDomainsMask = 0x0ffff | |
47 } | |
48 | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
49 const TNSStringPathExtensions = ` |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
50 |
14 | 51 static NSString pathWithComponents (NSArray components) |
52 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
53 return invokeObjcSuperClass!(NSString, "pathWithComponents:", NSArray)(components); |
14 | 54 } |
55 | |
56 NSArray pathComponents () | |
57 { | |
58 return invokeObjcSelf!(NSArray, "pathComponents"); | |
59 } | |
60 | |
61 bool isAbsolutePath () | |
62 { | |
63 return invokeObjcSelf!(bool, "isAbsolutePath"); | |
64 } | |
65 | |
66 NSString lastPathComponent () | |
67 { | |
68 return invokeObjcSelf!(NSString, "lastPathComponent"); | |
69 } | |
70 | |
71 NSString stringByDeletingLastPathComponent () | |
72 { | |
73 return invokeObjcSelf!(NSString, "stringByDeletingLastPathComponent"); | |
74 } | |
75 | |
76 NSString stringByAppendingPathComponent (NSString str) | |
77 { | |
78 return invokeObjcSelf!(NSString, "stringByAppendingPathComponent:", NSString)(str); | |
79 } | |
80 | |
81 NSString pathExtension () | |
82 { | |
83 return invokeObjcSelf!(NSString, "pathExtension"); | |
84 } | |
85 | |
86 NSString stringByDeletingPathExtension () | |
87 { | |
88 return invokeObjcSelf!(NSString, "stringByDeletingPathExtension"); | |
89 } | |
90 | |
91 NSString stringByAppendingPathExtension (NSString str) | |
92 { | |
93 return invokeObjcSelf!(NSString, "stringByAppendingPathExtension:", NSString)(str); | |
94 } | |
95 | |
96 NSString stringByAbbreviatingWithTildeInPath () | |
97 { | |
98 return invokeObjcSelf!(NSString, "stringByAbbreviatingWithTildeInPath"); | |
99 } | |
100 | |
101 NSString stringByExpandingTildeInPath () | |
102 { | |
103 return invokeObjcSelf!(NSString, "stringByExpandingTildeInPath"); | |
104 } | |
105 | |
106 NSString stringByStandardizingPath () | |
107 { | |
108 return invokeObjcSelf!(NSString, "stringByStandardizingPath"); | |
109 } | |
110 | |
111 NSString stringByResolvingSymlinksInPath () | |
112 { | |
113 return invokeObjcSelf!(NSString, "stringByResolvingSymlinksInPath"); | |
114 } | |
115 | |
116 NSArray stringsByAppendingPaths (NSArray paths) | |
117 { | |
118 return invokeObjcSelf!(NSArray, "stringsByAppendingPaths:", NSArray)(paths); | |
119 } | |
120 | |
121 NSUInteger completePathIntoString (NSString** outputName, bool flag, NSArray** outputArray, NSArray filterTypes) | |
122 { | |
123 return invokeObjcSelf!(NSUInteger, "completePathIntoString:caseSensitive:matchesIntoArray:filterTypes:", NSString**, bool, NSArray**, NSArray)(outputName, flag, outputArray, filterTypes); | |
124 } | |
125 | |
126 char* fileSystemRepresentation () | |
127 { | |
128 return invokeObjcSelf!(char*, "fileSystemRepresentation"); | |
129 } | |
130 | |
131 bool getFileSystemRepresentation (char* cname, NSUInteger max) | |
132 { | |
133 return invokeObjcSelf!(bool, "getFileSystemRepresentation:maxLength:", char*, NSUInteger)(cname, max); | |
134 } | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
135 `; |
14 | 136 |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
137 const TNSArrayPathExtensions = ` |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
138 |
14 | 139 NSArray pathsMatchingExtensions (NSArray filterTypes) |
140 { | |
141 return invokeObjcSelf!(NSArray, "pathsMatchingExtensions:", NSArray)(filterTypes); | |
142 } | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
143 `; |
14 | 144 |
145 NSString NSUserName () | |
146 { | |
147 return Bridge.invokeObjcFunction!(NSString, bindings.NSUserName); | |
148 } | |
149 | |
150 NSString NSFullUserName () | |
151 { | |
152 return Bridge.invokeObjcFunction!(NSString, bindings.NSFullUserName); | |
153 } | |
154 | |
155 NSString NSHomeDirectory () | |
156 { | |
157 return Bridge.invokeObjcFunction!(NSString, bindings.NSHomeDirectory); | |
158 } | |
159 | |
160 NSString NSHomeDirectoryForUser (NSString userName) | |
161 { | |
162 return Bridge.invokeObjcFunction!(NSString, bindings.NSHomeDirectoryForUser, NSString)(userName); | |
163 } | |
164 | |
165 NSString NSTemporaryDirectory () | |
166 { | |
167 return Bridge.invokeObjcFunction!(NSString, bindings.NSTemporaryDirectory); | |
168 } | |
169 | |
170 NSString NSOpenStepRootDirectory () | |
171 { | |
172 return Bridge.invokeObjcFunction!(NSString, bindings.NSOpenStepRootDirectory); | |
173 } | |
174 | |
175 NSArray NSSearchPathForDirectoriesInDomains (uint directory, uint domainMask, bool expandTilde) | |
176 { | |
177 return Bridge.invokeObjcFunction!(NSArray, bindings.NSSearchPathForDirectoriesInDomains, uint, uint, bool)(directory, domainMask, expandTilde); | |
178 } | |
179 |