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

Changeset 3445

Show
Ignore:
Timestamp:
04/18/08 01:10:05 (6 months ago)
Author:
kris
Message:

fixes #765 :: FilePath?: head/tail splitting

Thanks to DRK for this

Files:

Legend:

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

    r3442 r3445  
    11211121/******************************************************************************* 
    11221122 
     1123        Break a path into "head" and "tail" components. For example:  
     1124        --- 
     1125        "/a/b/c" -> "/a","b/c"  
     1126        "a/b/c" -> "a","b/c"  
     1127        --- 
     1128 
     1129*******************************************************************************/ 
     1130 
     1131char[] split (char[] path, out char[] head, out char[] tail) 
     1132{ 
     1133        head = path; 
     1134        if (path.length > 1) 
     1135            foreach (i, char c; path[1..$]) 
     1136                     if (c is '/') 
     1137                        { 
     1138                        head = path [0 .. i+1]; 
     1139                        tail = path [i+2 .. $]; 
     1140                        break; 
     1141                        } 
     1142        return path; 
     1143} 
     1144 
     1145/******************************************************************************* 
     1146 
    11231147        Replace all path 'from' instances with 'to' 
    11241148 
     
    11341158 
    11351159 
     1160 
    11361161/******************************************************************************* 
    11371162