Skip to content

Commit 80bd38b

Browse files
committed
Support long paths on Windows
1 parent 284d8e5 commit 80bd38b

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

mloader/exporter.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from mloader.constants import Language
88
from mloader.response_pb2 import Title, Chapter
9-
from mloader.utils import escape_path, is_oneshot, chapter_name_to_int
9+
from mloader.utils import escape_path, is_oneshot, chapter_name_to_int, is_windows
1010

1111

1212
class ExporterBase(metaclass=ABCMeta):
@@ -20,6 +20,11 @@ def __init__(
2020
add_chapter_subdir: bool = False
2121
):
2222
self.destination = destination
23+
24+
if is_windows():
25+
destination = Path(self.destination).resolve().as_posix()
26+
self.destination = f"\\\\?\\{destination}"
27+
2328
self.add_chapter_title = add_chapter_title
2429
self.add_chapter_subdir = add_chapter_subdir
2530
self.title_name = escape_path(title.name).title()

mloader/utils.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import re
22
import string
3+
import sys
34
from typing import Optional
45

56

@@ -20,3 +21,7 @@ def chapter_name_to_int(name: str) -> Optional[int]:
2021

2122
def escape_path(path: str) -> str:
2223
return re.sub(r"[^\w]+", " ", path).strip(string.punctuation + " ")
24+
25+
26+
def is_windows() -> bool:
27+
return sys.platform == "win32"

0 commit comments

Comments
 (0)