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

Changeset 3843

Show
Ignore:
Timestamp:
08/03/08 16:53:10 (4 months ago)
Author:
kris
Message:

fixes #1210 :: Path.standard does not convert

FilePath? does automatic conversion of '\' into '/', since it represents a mutable path. Path.parse(), on the other hand, does not since it has only a char[] to deal with. Const will perhaps make a mockery of this :(

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/tango/io/FilePath.d

    r3840 r3843  
    614614        /*********************************************************************** 
    615615 
    616                 Parse the path spec 
     616                Parse the path spec, and mutate '\' into '/' as necessary 
    617617 
    618618        ***********************************************************************/ 
     
    620620        private final FilePath parse () 
    621621        { 
    622                 p.parse (p.fp, p.end_); 
     622                p.parse (p.fp, p.end_, true); 
    623623                return this; 
    624624        } 
     
    13521352                fp = new FilePath(r"C:/foo/bar/test.bar"); 
    13531353                assert (fp.path == "C:/foo/bar/"); 
    1354                 fp = new FilePath(r"C:/foo/bar/test.bar"); 
     1354                fp = new FilePath(r"C:\foo\bar\test.bar"); 
    13551355                assert (fp.path == r"C:/foo/bar/"); 
    13561356 
  • trunk/tango/io/Path.d

    r3840 r3843  
    934934        PathParser parse (char[] path) 
    935935        { 
    936                 return parse (path, path.length); 
     936                return parse (path, path.length, false); 
    937937        } 
    938938 
     
    11421142        ***********************************************************************/ 
    11431143 
    1144         package PathParser parse (char[] path, uint end
     1144        package PathParser parse (char[] path, uint end, bool mutate
    11451145        { 
    11461146                end_ = end; 
     
    11581158                                 break; 
    11591159 
     1160                            case '\\': 
     1161                                 if (mutate is false) 
     1162                                     throw new IOException ("unexpected '\\' character in path: "~path); 
     1163                                 else 
     1164                                    fp[i] = '/'; 
     1165                                    // fall through! 
     1166 
    11601167                            case FileConst.PathSeparatorChar: 
    11611168                                 if (name_ < 0) 
    11621169                                     name_ = i + 1; 
    11631170                                 break; 
    1164  
    1165                             case '\\': 
    1166                                  throw new IOException ("unexpected '\\' character in path: "~path); 
    11671171 
    11681172                            version (Win32)