Skip to content

Commit 84806d7

Browse files
theotherjimmyCruz Monrreal II
authored andcommitted
Correct path handling after calls to win_to_unix
1 parent 0093758 commit 84806d7

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

tools/resources/__init__.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ def __init__(self, notify, collect_ignores=False):
137137
self._label_paths = []
138138
self._labels = {"TARGET": [], "TOOLCHAIN": [], "FEATURE": []}
139139

140-
# Should we convert all paths to unix-style?
141-
self._win_to_unix = False
140+
# Path seperator style (defaults to OS-specific seperator)
141+
self._sep = sep
142142

143143
# Ignore patterns from .mbedignore files and add_ignore_patters
144144
self._ignore_patterns = []
@@ -181,11 +181,12 @@ def detect_duplicates(self):
181181
return count
182182

183183
def win_to_unix(self):
184-
self._win_to_unix = True
185-
for file_type in self.ALL_FILE_TYPES:
186-
v = [f._replace(name=f.name.replace('\\', '/')) for
187-
f in self.get_file_refs(file_type)]
188-
self._file_refs[file_type] = v
184+
self._sep = "/"
185+
if self._sep != sep:
186+
for file_type in self.ALL_FILE_TYPES:
187+
v = [f._replace(name=f.name.replace(sep, self._sep)) for
188+
f in self.get_file_refs(file_type)]
189+
self._file_refs[file_type] = v
189190

190191
def __str__(self):
191192
s = []
@@ -262,8 +263,8 @@ def _not_current_label(self, dirname, label_type):
262263
dirname[len(label_type) + 1:] not in self._labels[label_type])
263264

264265
def add_file_ref(self, file_type, file_name, file_path):
265-
if self._win_to_unix:
266-
ref = FileRef(file_name.replace("\\", "/"), file_path)
266+
if sep != self._sep:
267+
ref = FileRef(file_name.replace(sep, self._sep), file_path)
267268
else:
268269
ref = FileRef(file_name, file_path)
269270
self._file_refs[file_type].add(ref)
@@ -272,12 +273,11 @@ def get_file_refs(self, file_type):
272273
"""Return a list of FileRef for every file of the given type"""
273274
return list(self._file_refs[file_type])
274275

275-
@staticmethod
276-
def _all_parents(files):
276+
def _all_parents(self, files):
277277
for name in files:
278-
components = name.split(sep)
278+
components = name.split(self._sep)
279279
for n in range(1, len(components)):
280-
parent = join(*components[:n])
280+
parent = self._sep.join(components[:n])
281281
yield parent
282282

283283
def _get_from_refs(self, file_type, key):

0 commit comments

Comments
 (0)