Skip to content

Commit

Permalink
Fix #264: 修复当路径中包含连续多个.时创建的文件夹路径不符合预期的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuukiy committed Apr 1, 2024
1 parent 1ca6b8c commit 378d43f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions core/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ def get_failed_when_scan():
return failed_items


_PARDIR_REPLACE = re.compile(r'\.{2,}')
def replace_illegal_chars(name):
"""将不能用于文件名的字符替换为形近的字符"""
# 非法字符列表 https://stackoverflow.com/a/31976060/6415337
Expand All @@ -185,6 +186,9 @@ def replace_illegal_chars(name):
name = name.replace(':', ':')
else: # 其余都当做Linux处理
name = name.replace('/', '/')
# 处理连续多个英文句点.
if os.pardir in name:
name = _PARDIR_REPLACE.sub('…', name)
return name


Expand Down

0 comments on commit 378d43f

Please sign in to comment.