aboutsummaryrefslogtreecommitdiffstats
path: root/youtube_dlc/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'youtube_dlc/utils.py')
-rw-r--r--youtube_dlc/utils.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/youtube_dlc/utils.py b/youtube_dlc/utils.py
index 1ec30bafd..6740f0cdb 100644
--- a/youtube_dlc/utils.py
+++ b/youtube_dlc/utils.py
@@ -5893,3 +5893,15 @@ _HEX_TABLE = '0123456789abcdef'
def random_uuidv4():
return re.sub(r'[xy]', lambda x: _HEX_TABLE[random.randint(0, 15)], 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx')
+
+
+def make_dir(path, to_screen=None):
+ try:
+ dn = os.path.dirname(path)
+ if dn and not os.path.exists(dn):
+ os.makedirs(dn)
+ return True
+ except (OSError, IOError) as err:
+ if callable(to_screen) is not None:
+ to_screen('unable to create directory ' + error_to_compat_str(err))
+ return False