Changeset 1641
- Timestamp:
- 02/08/07 20:58:27 (2 years ago)
- Files:
-
- trunk/tango/io/FilePath.d (modified) (4 diffs)
- trunk/tango/io/FileSystem.d (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/tango/io/FilePath.d
r1586 r1641 308 308 /*********************************************************************** 309 309 310 Join this FilePath with the provided prefix. 311 312 Assumes prefix is a directory name. If this is an absolute 313 path it will be returned intact, ignoring prefix. 314 315 ***********************************************************************/ 316 317 final FilePath join (char[] prefix) 318 { 319 if (isAbsolute) 320 return this; 321 322 return new FilePath (asPadded(prefix) ~ toUtf8); 323 } 324 325 /*********************************************************************** 326 327 Join this FilePath with the provided prefix. 328 329 Assumes prefix is a directory name. If this is an absolute 330 path it will be returned intact, ignoring prefix. 331 332 ***********************************************************************/ 333 334 final FilePath join (FilePath prefix) 335 { 336 return join (prefix.toUtf8); 310 Join this FilePath with the provided suffix 311 312 ***********************************************************************/ 313 314 final char[] append (char[] path) 315 { 316 return asPadded(toUtf8) ~ path; 317 } 318 319 /*********************************************************************** 320 321 Join this FilePath with the provided suffix 322 323 ***********************************************************************/ 324 325 final FilePath append (FilePath path) 326 { 327 return new FilePath (append (path.toUtf8)); 328 } 329 330 /*********************************************************************** 331 332 Join a set of path specs together. A path separator is 333 potentially inserted between each of the segments. 334 335 ***********************************************************************/ 336 337 static char[] join (char[][] paths...) 338 { 339 char[] result; 340 341 foreach (path; paths) 342 result ~= asPadded (path); 343 344 return result.length ? result [0 .. $-1] : null; 337 345 } 338 346 … … 515 523 debug (UnitTest) 516 524 { 525 void main() {} 526 517 527 unittest 518 528 { … … 679 689 assert (fp.getExt == ""); 680 690 681 fp = new FilePath(r"foo\bar\");682 assert(fp.join(r"c:\joe\bar").toUtf8 == r"c:\joe\bar\foo\bar\");683 assert(fp.join(new FilePath(r"c:\joe\bar")).toUtf8 == r"c:\joe\bar\foo\bar\");684 691 fp = new FilePath(r"c:\joe\bar"); 685 assert(fp.join(r"foo\bar\").toUtf8 == r"c:\joe\bar"); 686 assert(fp.join(new FilePath(r"foo\bar")).toUtf8 == r"c:\joe\bar"); 687 688 fp = new FilePath(r"c:\bar"); 689 assert(fp.join(r"foo").toUtf8 == r"c:\bar"); 690 assert(fp.join(new FilePath(r"foo")).toUtf8 == r"c:\bar"); 691 692 fp = new FilePath(r"bar\"); 693 assert(fp.join(r"c:\foo").toUtf8 == r"c:\foo\bar\"); 694 assert(fp.join(new FilePath(r"c:\foo")).toUtf8 == r"c:\foo\bar\"); 692 assert(fp.append(r"foo\bar\") == r"c:\joe\bar\foo\bar\"); 693 assert(fp.append(new FilePath(r"foo\bar")).toUtf8 == r"c:\joe\bar\foo\bar"); 694 695 assert (FilePath.join (r"a\b\c\d", r"e\f\" r"g") == r"a\b\c\d\e\f\g"); 695 696 696 697 fp = new FilePath(r"C:\foo\bar\test.bar"); … … 863 864 assert (fp.getExt == ""); 864 865 865 fp = new FilePath(r"foo/bar/"); 866 assert(fp.join(r"/joe/bar").toUtf8 == r"/joe/bar/foo/bar/"); 867 assert(fp.join(new FilePath(r"/joe/bar")).toUtf8 == r"/joe/bar/foo/bar/"); 868 fp = new FilePath(r"/joe/bar"); 869 assert(fp.join(r"foo/bar/").toUtf8 == r"/joe/bar"); 870 assert(fp.join(new FilePath(r"foo/bar")).toUtf8 == r"/joe/bar"); 871 872 fp = new FilePath(r"/bar"); 873 assert(fp.join(r"foo").toUtf8 == r"/bar"); 874 assert(fp.join(new FilePath(r"foo")).toUtf8 == r"/bar"); 875 876 fp = new FilePath(r"bar/"); 877 assert(fp.join(r"/foo").toUtf8 == r"/foo/bar/"); 878 assert(fp.join(new FilePath(r"/foo")).toUtf8 == r"/foo/bar/"); 866 fp = new FilePath("/joe/bar"); 867 assert(fp.append("foo/bar/") == "/joe/bar/foo/bar/"); 868 assert(fp.append(new FilePath("foo/bar")).toUtf8 == "/joe/bar/foo/bar"); 869 870 assert (FilePath.join ("a/b/c/d", "e/f/" "g") == "a/b/c/d/e/f/g"); 879 871 880 872 fp = new FilePath(r"/foo/bar/test.bar"); trunk/tango/io/FileSystem.d
r1464 r1641 54 54 return path; 55 55 56 return path.join (getDirectory);56 return getDirectory.append (path); 57 57 } 58 58












