if (exists ("some/file/path"))
...
These functions may be less efficient than FilePath because they
generally attach a null to the filename for each underlying O/S
call. Use Path when you need pedestrian access to the file-system,
and are not manipulating the path components. Use FilePath where
path-editing or mutation is desired.
import Path = tango.io.Path;
if (Path.exists ("some/file/path"))
...
Also residing here is a lightweight path-parser, which splits a
filepath into constituent components. FilePath is based upon the
same PathParser:
auto p = Path.parse ("some/file/path");
auto path = p.path;
auto name = p.name;
auto suffix = p.suffix;
...
Path normalization and pattern-matching is also hosted here via
the normalize() and pattern() functions. See the doc towards the
end of this module.
remove (collate (".", "*.d", true));
Use with great caution.
foreach (info; children("myfolder"))
...
char[] path
char[] name
ulong bytes
bool folder
Argument 'all' controls whether hidden and system
files are included - these are ignored by default.| * | Matches 0 or more instances of any character. |
| ? | Matches exactly one instances of any character. |
| [] | Matches one instance of any character that appears between the brackets. |
| [!] | Matches one instance of any character that does not appear between the brackets after the exclamation mark. |
version (Win32)
{
patternMatch("foo.bar", "*"); // => true
patternMatch(r"foo/foo\bar", "f*b*r"); // => true
patternMatch("foo.bar", "f?bar"); // => false
patternMatch("Goo.bar", "[fg]???bar"); // => true
patternMatch(r"d:\foo\bar", "d*foo?bar"); // => true
}
version (Posix)
{
patternMatch("Go*.bar", "[fg]???bar"); // => false
patternMatch("/foo*home/bar", "?foo*bar"); // => true
patternMatch("foobar", "foo?bar"); // => true
}
normalize("/home/foo/./bar/../../john/doe"); // => "/home/john/doe"