mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-04 04:02:41 +00:00
committed by
Andreas Rumpf
parent
bf96d6d316
commit
b355ef2a72
@@ -353,8 +353,10 @@ proc relativePath*(path, base: string; sep = DirSep): string {.
|
||||
assert relativePath("/Users///me/bar//z.nim", "//Users/", '/') == "me/bar/z.nim"
|
||||
assert relativePath("/Users/me/bar/z.nim", "/Users/me", '/') == "bar/z.nim"
|
||||
assert relativePath("", "/users/moo", '/') == ""
|
||||
assert relativePath("foo", ".", '/') == "foo"
|
||||
|
||||
if path.len == 0: return ""
|
||||
let base = if base == ".": "" else: base
|
||||
|
||||
when doslikeFileSystem:
|
||||
if isAbsolute(path) and isAbsolute(base):
|
||||
|
||||
@@ -334,6 +334,10 @@ block ospaths:
|
||||
doAssert relativePath("/foo", "/fOO", '/') == (when FileSystemCaseSensitive: "../foo" else: "")
|
||||
doAssert relativePath("/foO", "/foo", '/') == (when FileSystemCaseSensitive: "../foO" else: "")
|
||||
|
||||
doAssert relativePath("foo", ".", '/') == "foo"
|
||||
doAssert relativePath(".", ".", '/') == "."
|
||||
doAssert relativePath("..", ".", '/') == ".."
|
||||
|
||||
when doslikeFileSystem:
|
||||
doAssert relativePath(r"c:\foo.nim", r"C:\") == r"foo.nim"
|
||||
doAssert relativePath(r"c:\foo\bar\baz.nim", r"c:\foo") == r"bar\baz.nim"
|
||||
|
||||
Reference in New Issue
Block a user