Skip to content

Commit

Permalink
Glob: Fix file path manipulation on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
fneu committed May 4, 2015
1 parent 3e1f1c3 commit 3bd6eb3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions coalib/parsing/Glob.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,14 @@ def iglob(pattern, files=True, dirs=True):
raise StopIteration()

for pat in _iter_or_combinations(pattern):
pattern_parts = pat.split(os.sep) # "/a/b.py" -> ['', 'a', 'b.py']
# extract drive letter, if possible:
drive_letter, pat = os.path.splitdrive(pat)
# "/a/b.py" -> ['', 'a', 'b.py'] or \\a\\b.py -> ['', 'a', 'b.py']
pattern_parts = pat.split(os.sep)
# replace first pattern part with absolute path root if empty
if pat.startswith(os.sep):
pattern_parts[0] = os.sep # would be '' instead
pattern_parts[0] = drive_letter and drive_letter + "\\" or os.sep

selector = _make_selector(pattern_parts)

for p in selector.collect():
Expand Down

0 comments on commit 3bd6eb3

Please sign in to comment.