22import stat
33from os import walk , path , listdir , rmdir , sep
44from os .path import split , relpath , abspath
5+ from pathlib import PurePath
56
67from cloudinary_cli .defaults import logger
78from cloudinary_cli .utils .utils import etag
@@ -45,7 +46,7 @@ def walk_dir(root_dir, include_hidden=False):
4546 files = [f for f in files if not is_hidden (root , f )]
4647 dirs [:] = [d for d in dirs if not is_hidden (root , d )]
4748
48- relative_path = relpath (root , root_dir ) if root_dir != root else ""
49+ relative_path = posix_rel_path (root , root_dir ) if root_dir != root else ""
4950 for file in files :
5051 full_path = path .join (root , file )
5152 relative_file_path = "/" .join (p for p in [relative_path , file ] if p )
@@ -107,7 +108,7 @@ def get_destination_folder(cloudinary_folder: str, file_path: str, parent: str =
107108 folder_path = []
108109
109110 parent_path = abspath (parent ) if parent else None
110- splitted = split (relpath (file_path , parent_path ))
111+ splitted = split (posix_rel_path (file_path , parent_path ))
111112
112113 if splitted [0 ]:
113114 folder_path = splitted [0 ].split (sep )
@@ -127,3 +128,14 @@ def normalize_file_extension(filename: str) -> str:
127128 extension_alias = FORMAT_ALIASES .get (extension , extension )
128129
129130 return "." .join ([p for p in [filename , extension_alias ] if p ])
131+
132+
133+ def posix_rel_path (end , start ) -> str :
134+ """
135+ Returns a relative path in posix style on any system.
136+
137+ :param end: The end path.
138+ :param start: The start path.
139+ :return: The Relative path.
140+ """
141+ return PurePath (relpath (end , start )).as_posix ()
0 commit comments