Skip to content

Commit

Permalink
fix(windows): improve case insensitive path handling
Browse files Browse the repository at this point in the history
  • Loading branch information
citycide committed Jul 24, 2018
1 parent a03cb7c commit 4a0d545
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/glob.nim
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,18 @@ func hasMagic* (str: string): bool =

str.contains({'*', '?', '[', '{'}) or str.contains(re"[?!@+]\(")

# use this in the future (when/if merged)
# https://github.com/nim-lang/Nim/pull/8166
func toRelative (path, dir: string): string =
if path.startsWith(dir):
let (innerPath, innerDir) =
when defined FileSystemCaseSensitive: (path, dir)
else: (path.toLowerAscii, dir.toLowerAscii)

if innerPath.startsWith(innerDir):
let start = dir.len + dir.endsWith(DirSep).not.int
path[start..<path.len]
return path[start..<path.len]
else:
path
return path

proc pathType (path: string, kind: var PathComponent): bool =
try:
Expand Down

0 comments on commit 4a0d545

Please sign in to comment.