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