view tango/example/system/normpath.d @ 341:1bb99290e03a trunk

[svn r362] Started merging the old 'test' dir as well as the newer 'tangotests' dir into 'tests/mini' and 'tests/minicomplex'.
author lindquist
date Sun, 13 Jul 2008 02:51:19 +0200
parents 1700239cab2e
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;
}