Skip to content

Commit 89fcaf1

Browse files
authored
Merge pull request #84 from wintoncode/handle-root-dir-home-on-windows
Fixed failure when a user's home dir is a drive root on Windows
2 parents 7f414c8 + e38ada1 commit 89fcaf1

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

msal_extensions/persistence.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import os
1111
import errno
1212
import logging
13+
import sys
1314
try:
1415
from pathlib import Path # Built-in in Python 3
1516
except:
@@ -28,14 +29,19 @@
2829
def _mkdir_p(path):
2930
"""Creates a directory, and any necessary parents.
3031
31-
This implementation based on a Stack Overflow question that can be found here:
32-
https://stackoverflow.com/questions/600268/mkdir-p-functionality-in-python
33-
3432
If the path provided is an existing file, this function raises an exception.
3533
:param path: The directory name that should be created.
3634
"""
3735
if not path:
3836
return # NO-OP
37+
38+
if sys.version_info >= (3, 2):
39+
os.makedirs(path, exist_ok=True)
40+
return
41+
42+
# This fallback implementation is based on a Stack Overflow question:
43+
# https://stackoverflow.com/questions/600268/mkdir-p-functionality-in-python
44+
# Known issue: it won't work when the path is a root folder like "C:\\"
3945
try:
4046
os.makedirs(path)
4147
except OSError as exp:

0 commit comments

Comments
 (0)