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

Changeset 3849

Show
Ignore:
Timestamp:
08/03/08 17:48:34 (4 months ago)
Author:
kris
Message:

more fixes related to #1210

Now have to convert paths on each call to set(), given const issues. This sucks

Files:

Legend:

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

    r3843 r3849  
    114114        this (char[] filepath = null) 
    115115        { 
    116                 set (filepath); 
     116                set (filepath, true); 
    117117        } 
    118118         
     
    428428        FilePath set (FilePath path) 
    429429        { 
    430                 return set (path.toString); 
    431         } 
    432  
    433         /*********************************************************************** 
    434  
    435                 Reset the content of this path, and reparse.  
    436  
    437         ***********************************************************************/ 
    438  
    439         final FilePath set (char[] path) 
     430                return set (path.toString, false); 
     431        } 
     432 
     433        /*********************************************************************** 
     434 
     435                Reset the content of this path, and reparse. There's an 
     436                optional boolean flag to convert the path into standard 
     437                form, before parsing (converting '\' into '/') 
     438 
     439        ***********************************************************************/ 
     440 
     441        final FilePath set (char[] path, bool convert = false) 
    440442        { 
    441443                p.end_ = path.length; 
     
    443445                expand (p.end_); 
    444446                if (p.end_) 
    445                     p.fp[0 .. p.end_] = path; 
     447                   { 
     448                   p.fp[0 .. p.end_] = path; 
     449                   if (convert) 
     450                       .standard (p.fp [0 .. p.end_]); 
     451                   } 
    446452 
    447453                p.fp[p.end_] = '\0'; 
     
    620626        private final FilePath parse () 
    621627        { 
    622                 p.parse (p.fp, p.end_, true); 
     628                p.parse (p.fp, p.end_); 
    623629                return this; 
    624630        } 
     
    921927        { 
    922928                FS.rename (cString, dst~'\0'); 
    923                 return this.set (dst); 
     929                return this.set (dst, true); 
    924930        } 
    925931 
  • trunk/tango/io/Path.d

    r3843 r3849  
    160160        static void exception (char[] filename) 
    161161        { 
    162                 throw new IOException (filename[0..$-1] ~ ": " ~ SysError.lastMsg); 
     162                exception (filename[0..$-1] ~ ": ", SysError.lastMsg); 
     163        } 
     164 
     165        /*********************************************************************** 
     166 
     167                Throw an IO exception  
     168 
     169        ***********************************************************************/ 
     170 
     171        static void exception (char[] prefix, char[] error) 
     172        { 
     173                throw new IOException (prefix ~ error); 
    163174        } 
    164175 
     
    934945        PathParser parse (char[] path) 
    935946        { 
    936                 return parse (path, path.length, false); 
     947                return parse (path, path.length); 
    937948        } 
    938949 
     
    11421153        ***********************************************************************/ 
    11431154 
    1144         package PathParser parse (char[] path, uint end, bool mutate
     1155        package PathParser parse (char[] path, uint end
    11451156        { 
    11461157                end_ = end; 
     
    11581169                                 break; 
    11591170 
    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  
    11671171                            case FileConst.PathSeparatorChar: 
    11681172                                 if (name_ < 0) 
    11691173                                     name_ = i + 1; 
    11701174                                 break; 
     1175 
     1176                            // Windows file separators are illegal. Use 
     1177                            // standard() or equivalent to convert first 
     1178                            case '\\': 
     1179                                 FS.exception ("unexpected '\\' character in path: ", path); 
    11711180 
    11721181                            version (Win32)