Mercurial > projects > ldc
view tango/example/system/normpath.d @ 132:1700239cab2e trunk
[svn r136] MAJOR UNSTABLE UPDATE!!!
Initial commit after moving to Tango instead of Phobos.
Lots of bugfixes...
This build is not suitable for most things.
author | lindquist |
---|---|
date | Fri, 11 Jan 2008 17:57:40 +0100 |
parents | |
children |
line wrap: on
line source
/***************************************************************** Simple example that shows possible inputs to normalize and the corresponding outputs. Put into public domain by Lars Ivar Igesund. *****************************************************************/ import tango.io.Stdout; import tango.util.PathUtil; int main() { version (Posix) { Stdout(normalize ( "/foo/../john")).newline; Stdout(normalize ( "foo/../john")).newline; Stdout(normalize ( "foo/bar/..")).newline; Stdout(normalize ( "foo/bar/../john")).newline; Stdout(normalize ( "foo/bar/doe/../../john")).newline; Stdout(normalize ( "foo/bar/doe/../../john/../bar")).newline; Stdout(normalize ( "./foo/bar/doe")).newline; Stdout(normalize ( "./foo/bar/doe/../../john/../bar")).newline; Stdout(normalize ( "./foo/bar/../../john/../bar")).newline; Stdout(normalize ( "foo/bar/./doe/../../john")).newline; Stdout(normalize ( "../../foo/bar/./doe/../../john")).newline; Stdout(normalize ( "../../../foo/bar")).newline; Stdout("** Should now throw exception as the following path is invalid for normalization.").newline; Stdout(normalize ( "/../../../foo/bar")).newline; } version (Windows) { Stdout(normalize ( "C:\\foo\\..\\john")).newline; Stdout(normalize ( "foo\\..\\john")).newline; Stdout(normalize ( "foo\\bar\\..")).newline; Stdout(normalize ( "foo\\bar\\..\\john")).newline; Stdout(normalize ( "foo\\bar\\doe\\..\\..\\john")).newline; Stdout(normalize ( "foo\\bar\\doe\\..\\..\\john\\..\\bar")).newline; Stdout(normalize ( ".\\foo\\bar\\doe")).newline; Stdout(normalize ( ".\\foo\\bar\\doe\\..\\..\\john\\..\\bar")).newline; Stdout(normalize ( ".\\foo\\bar\\..\\..\\john\\..\\bar")).newline; Stdout(normalize ( "foo\\bar\\.\\doe\\..\\..\\john")).newline; Stdout(normalize ( "..\\..\\foo\\bar\\.\\doe\\..\\..\\john")).newline; Stdout(normalize ( "..\\..\\..\\foo\\bar")).newline; Stdout("** Should now throw exception as the following path is invalid for normalization.").newline; Stdout(normalize ( "C:\\..\\..\\..\\foo\\bar")).newline; } return 0; }