 |
Changeset 3445
- 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
| r3442 |
r3445 |
|
| 1121 | 1121 | /******************************************************************************* |
|---|
| 1122 | 1122 | |
|---|
| | 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 | |
|---|
| | 1131 | char[] 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 | |
|---|
| 1123 | 1147 | Replace all path 'from' instances with 'to' |
|---|
| 1124 | 1148 | |
|---|
| … | … | |
| 1134 | 1158 | |
|---|
| 1135 | 1159 | |
|---|
| | 1160 | |
|---|
| 1136 | 1161 | /******************************************************************************* |
|---|
| 1137 | 1162 | |
|---|
Download in other formats:
|
 |
 |
|
 |
Copyright © 2006-2008 Tango. All Rights Reserved. | Page Width:
Static or
Dynamic