PathView

Members

Aliases

Stamps
alias Stamps = FS.Stamps
Undocumented in source.

Functions

cString
inout(char)[] cString()

Return the complete text of this filepath.

toString
immutable(char)[] toString()

Return the complete text of this filepath.

Properties

accessed
Time accessed [@property getter]

Returns the time of the last access. Accurate to whatever the OS supports.

created
Time created [@property getter]

Returns the time of file creation. Accurate to whatever the OS supports.

exists
bool exists [@property getter]

Does this path currently exist?

ext
char[] ext [@property getter]

Ext is the tail of the filename, rightward of the rightmost '.' separator e.g. path "foo.bar" has ext "bar". Note that patterns of adjacent separators are treated specially; for example, ".." will wind up with no ext at all.

file
inout(char)[] file [@property getter]

Return the name + suffix combination.

fileSize
ulong fileSize [@property getter]

Return the file length (in bytes).

folder
inout(char)[] folder [@property getter]

Return the file path. Paths may start and end with a "/". The root path is "/" and an unspecified path is returned as an empty string. Directory paths may be split such that the directory name is placed into the 'name' member; directory paths are treated no differently than file paths.

isAbsolute
bool isAbsolute [@property getter]

Returns true if this FilePath is *not* relative to the current working directory.

isChild
bool isChild [@property getter]

Returns true if this FilePath has a parent.

isEmpty
bool isEmpty [@property getter]

Returns true if this FilePath is empty.

isFolder
bool isFolder [@property getter]

Is this file actually a folder/directory?

isWritable
bool isWritable [@property getter]

Is this file writable?

modified
Time modified [@property getter]

Returns the time of the last modification. Accurate to whatever the OS supports.

name
inout(char)[] name [@property getter]

Return the name of this file, or directory, excluding a suffix.

path
inout(char)[] path [@property getter]

Return the root + folder combination.

root
inout(char)[] root [@property getter]

Return the root of this path. Roots are constructs such as "C:".

suffix
inout(char)[] suffix [@property getter]

Suffix is like ext, but includes the separator e.g. path "foo.bar" has suffix ".bar".

timeStamps
Stamps timeStamps [@property getter]

Return timestamp information.

Examples

1                 version(Win32)
2                 {
3                 assert (FilePath("/foo".dup).append("bar").pop() == "/foo");
4                 assert (FilePath("/foo/".dup).append("bar").pop() == "/foo");
5 
6                 auto fp = new FilePath(r"C:/home/foo/bar".dup);
7                 fp ~= "john";
8                 assert (fp == r"C:/home/foo/bar/john");
9                 fp.set (r"C:/");
10                 fp ~= "john";
11                 assert (fp == r"C:/john");
12                 fp.set("foo.bar");
13                 fp ~= "john";
14                 assert (fp == r"foo.bar/john");
15                 fp.set("");
16                 fp ~= "john";
17                 assert (fp == r"john");
18 
19                 fp.set(r"C:/home/foo/bar/john/foo.d".dup);
20                 assert (fp.pop() == r"C:/home/foo/bar/john");
21                 assert (fp.pop() == r"C:/home/foo/bar");
22                 assert (fp.pop() == r"C:/home/foo");
23                 assert (fp.pop() == r"C:/home");
24                 assert (fp.pop() == r"C:");
25                 assert (fp.pop() == r"C:");
26 
27                 // special case for popping empty names
28                 fp.set (r"C:/home/foo/bar/john/".dup);
29                 assert (fp.parent == r"C:/home/foo/bar");
30 
31                 fp = new FilePath;
32                 fp.set (r"C:/home/foo/bar/john/".dup);
33                 assert (fp.isAbsolute);
34                 assert (fp.name == "");
35                 assert (fp.folder == r"/home/foo/bar/john/");
36                 assert (fp == r"C:/home/foo/bar/john/");
37                 assert (fp.path == r"C:/home/foo/bar/john/");
38                 assert (fp.file == r"");
39                 assert (fp.suffix == r"");
40                 assert (fp.root == r"C:");
41                 assert (fp.ext == "");
42                 assert (fp.isChild);
43 
44                 fp = new FilePath(r"C:/home/foo/bar/john".dup);
45                 assert (fp.isAbsolute);
46                 assert (fp.name == "john");
47                 assert (fp.folder == r"/home/foo/bar/");
48                 assert (fp == r"C:/home/foo/bar/john");
49                 assert (fp.path == r"C:/home/foo/bar/");
50                 assert (fp.file == r"john");
51                 assert (fp.suffix == r"");
52                 assert (fp.ext == "");
53                 assert (fp.isChild);
54 
55                 fp.pop();
56                 assert (fp.isAbsolute);
57                 assert (fp.name == "bar");
58                 assert (fp.folder == r"/home/foo/");
59                 assert (fp == r"C:/home/foo/bar");
60                 assert (fp.path == r"C:/home/foo/");
61                 assert (fp.file == r"bar");
62                 assert (fp.suffix == r"");
63                 assert (fp.ext == "");
64                 assert (fp.isChild);
65 
66                 fp.pop();
67                 assert (fp.isAbsolute);
68                 assert (fp.name == "foo");
69                 assert (fp.folder == r"/home/");
70                 assert (fp == r"C:/home/foo");
71                 assert (fp.path == r"C:/home/");
72                 assert (fp.file == r"foo");
73                 assert (fp.suffix == r"");
74                 assert (fp.ext == "");
75                 assert (fp.isChild);
76 
77                 fp.pop();
78                 assert (fp.isAbsolute);
79                 assert (fp.name == "home");
80                 assert (fp.folder == r"/");
81                 assert (fp == r"C:/home");
82                 assert (fp.path == r"C:/");
83                 assert (fp.file == r"home");
84                 assert (fp.suffix == r"");
85                 assert (fp.ext == "");
86                 assert (fp.isChild);
87 
88                 fp = new FilePath(r"foo/bar/john.doe".dup);
89                 assert (!fp.isAbsolute);
90                 assert (fp.name == "john");
91                 assert (fp.folder == r"foo/bar/");
92                 assert (fp.suffix == r".doe");
93                 assert (fp.file == r"john.doe");
94                 assert (fp == r"foo/bar/john.doe");
95                 assert (fp.ext == "doe");
96                 assert (fp.isChild);
97 
98                 fp = new FilePath(r"c:doe".dup);
99                 assert (fp.isAbsolute);
100                 assert (fp.suffix == r"");
101                 assert (fp == r"c:doe");
102                 assert (fp.folder == r"");
103                 assert (fp.name == "doe");
104                 assert (fp.file == r"doe");
105                 assert (fp.ext == "");
106                 assert (!fp.isChild);
107 
108                 fp = new FilePath(r"/doe".dup);
109                 assert (fp.isAbsolute);
110                 assert (fp.suffix == r"");
111                 assert (fp == r"/doe");
112                 assert (fp.name == "doe");
113                 assert (fp.folder == r"/");
114                 assert (fp.file == r"doe");
115                 assert (fp.ext == "");
116                 assert (fp.isChild);
117 
118                 fp = new FilePath(r"john.doe.foo".dup);
119                 assert (!fp.isAbsolute);
120                 assert (fp.name == "john.doe");
121                 assert (fp.folder == r"");
122                 assert (fp.suffix == r".foo");
123                 assert (fp == r"john.doe.foo");
124                 assert (fp.file == r"john.doe.foo");
125                 assert (fp.ext == "foo");
126                 assert (!fp.isChild);
127 
128                 fp = new FilePath(r".doe".dup);
129                 assert (!fp.isAbsolute);
130                 assert (fp.suffix == r"");
131                 assert (fp == r".doe");
132                 assert (fp.name == ".doe");
133                 assert (fp.folder == r"");
134                 assert (fp.file == r".doe");
135                 assert (fp.ext == "");
136                 assert (!fp.isChild);
137 
138                 fp = new FilePath(r"doe".dup);
139                 assert (!fp.isAbsolute);
140                 assert (fp.suffix == r"");
141                 assert (fp == r"doe");
142                 assert (fp.name == "doe");
143                 assert (fp.folder == r"");
144                 assert (fp.file == r"doe");
145                 assert (fp.ext == "");
146                 assert (!fp.isChild);
147 
148                 fp = new FilePath(r".".dup);
149                 assert (!fp.isAbsolute);
150                 assert (fp.suffix == r"");
151                 assert (fp == r".");
152                 assert (fp.name == ".");
153                 assert (fp.folder == r"");
154                 assert (fp.file == r".");
155                 assert (fp.ext == "");
156                 assert (!fp.isChild);
157 
158                 fp = new FilePath(r"..".dup);
159                 assert (!fp.isAbsolute);
160                 assert (fp.suffix == r"");
161                 assert (fp == r"..");
162                 assert (fp.name == "..");
163                 assert (fp.folder == r"");
164                 assert (fp.file == r"..");
165                 assert (fp.ext == "");
166                 assert (!fp.isChild);
167 
168                 fp = new FilePath(r"c:/a/b/c/d/e/foo.bar".dup);
169                 assert (fp.isAbsolute);
170                 fp.folder (r"/a/b/c/");
171                 assert (fp.suffix == r".bar");
172                 assert (fp == r"c:/a/b/c/foo.bar");
173                 assert (fp.name == "foo");
174                 assert (fp.folder == r"/a/b/c/");
175                 assert (fp.file == r"foo.bar");
176                 assert (fp.ext == "bar");
177                 assert (fp.isChild);
178 
179                 fp = new FilePath(r"c:/a/b/c/d/e/foo.bar".dup);
180                 assert (fp.isAbsolute);
181                 fp.folder (r"/a/b/c/d/e/f/g/");
182                 assert (fp.suffix == r".bar");
183                 assert (fp == r"c:/a/b/c/d/e/f/g/foo.bar");
184                 assert (fp.name == "foo");
185                 assert (fp.folder == r"/a/b/c/d/e/f/g/");
186                 assert (fp.file == r"foo.bar");
187                 assert (fp.ext == "bar");
188                 assert (fp.isChild);
189 
190                 fp = new FilePath(r"C:/foo/bar/test.bar".dup);
191                 assert (fp.path == "C:/foo/bar/");
192                 fp = new FilePath(r"C:\foo\bar\test.bar".dup);
193                 assert (fp.path == r"C:/foo/bar/");
194 
195                 fp = new FilePath("".dup);
196                 assert (fp.isEmpty);
197                 assert (!fp.isChild);
198                 assert (!fp.isAbsolute);
199                 assert (fp.suffix == r"");
200                 assert (fp == r"");
201                 assert (fp.name == "");
202                 assert (fp.folder == r"");
203                 assert (fp.file == r"");
204                 assert (fp.ext == "");
205 /+
206                 fp = new FilePath(r"C:/foo/bar/test.bar");
207                 fp = new FilePath(fp.asPath ("foo"));
208                 assert (fp.name == r"test");
209                 assert (fp.folder == r"foo/");
210                 assert (fp.path == r"C:foo/");
211                 assert (fp.ext == ".bar");
212 
213                 fp = new FilePath(fp.asPath (""));
214                 assert (fp.name == r"test");
215                 assert (fp.folder == r"");
216                 assert (fp.path == r"C:");
217                 assert (fp.ext == ".bar");
218 
219                 fp = new FilePath(r"c:/joe/bar");
220                 assert(fp.cat(r"foo/bar/") == r"c:/joe/bar/foo/bar/");
221                 assert(fp.cat(new FilePath(r"foo/bar")).toString == r"c:/joe/bar/foo/bar");
222 
223                 assert (FilePath.join (r"a/b/c/d", r"e/f/" r"g") == r"a/b/c/d/e/f/g");
224 
225                 fp = new FilePath(r"C:/foo/bar/test.bar");
226                 assert (fp.asExt(null) == r"C:/foo/bar/test");
227                 assert (fp.asExt("foo") == r"C:/foo/bar/test.foo");
228 +/
229                 }
230 

Meta