Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Changeset 3414

Show
Ignore:
Timestamp:
04/05/08 19:00:30 (3 months ago)
Author:
larsivi
Message:

Removed possibility to specify normalization of slashes.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/tango/util/PathUtil.d

    r3402 r3414  
    2626    <segment>/../ in path is removed 
    2727 
    28     Unless normSlash is set to false, all slashes will be converted 
    29     to the systems path separator character. 
     28    On Windows, \ will be converted to / prior to normalization. 
    3029 
    3130    Note that any number of ../ segments at the front is ignored, 
     
    3534    be fully normalized. 
    3635 
    37     Throws: Exception if the root separator is followed by .. 
     36    Throws: IllegalArgumentException if the root separator is followed by .. 
    3837 
    3938    Examples: 
     
    4443*******************************************************************************/ 
    4544 
    46 char[] normalize(char[] path, bool normSlash = true) 
    47 
     45char[] normalize(char[] path) 
     46
     47 
     48version (Windows) { 
    4849    /* 
    4950       Internal helper to patch slashes 
     
    5859        return path; 
    5960    } 
     61} 
    6062 
    6163    /* 
     
    113115        else if (path[start..start+2] == "..") { 
    114116            // found /.. sequence 
    115 version (Win32) { 
     117version (Windows) { 
    116118            if (start == 3 && path[1] == '/') { // absolute, X:/.. 
    117                 throw new IllegalArgumentException("PathUtil :: Invalid absolute path, root can not be followed by .."); 
     119                throw new IllegalArgumentException("PathUtil :: Invalid absolute path, root can't be followed by .."); 
    118120            } 
    119121 
     
    121123else { 
    122124            if (start == 1) { // absolute 
    123                 throw new IllegalArgumentException("PathUtil :: Invalid absolute path, root separator can not be followed by .."); 
     125                throw new IllegalArgumentException("PathUtil :: Invalid absolute path, root separator can't be followed by .."); 
    124126            } 
    125127} 
     
    177179 
    178180    char[] normpath = path.dup; 
    179     if (normSlash) { 
    180         normpath = normalizeSlashes(normpath); 
    181    
     181version (Windows) { 
     182    normpath = normalizeSlashes(normpath); 
     183
    182184 
    183185    // if path starts with ./, remove all subsequent instances 
     
    228230        assert (normalize ("d/") == "d/"); 
    229231 
     232version (Windows) { 
    230233        assert (normalize ("\\foo\\..\\john") == "/john"); 
    231234        assert (normalize ("foo\\..\\john") == "john"); 
     
    240243        assert (normalize ("..\\..\\foo\\bar") == "../../foo/bar"); 
    241244        assert (normalize ("..\\..\\..\\foo\\bar") == "../../../foo/bar"); 
     245} 
    242246    } 
    243247}