summaryrefslogtreecommitdiff
path: root/src/leap/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/util')
-rw-r--r--src/leap/util/files.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/leap/util/files.py b/src/leap/util/files.py
index 8c7a5af3..97741433 100644
--- a/src/leap/util/files.py
+++ b/src/leap/util/files.py
@@ -1,7 +1,29 @@
+# -*- coding: utf-8 -*-
+# files.py
+# Copyright (C) 2013 LEAP
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+"""
+Implements file helper methods
+"""
+
import os
import stat
import logging
import time
+import errno
logger = logging.getLogger(__name__)
@@ -43,3 +65,22 @@ def get_mtime(filename):
return mtime
except OSError:
return None
+
+
+def mkdir_p(path):
+ """
+ Creates the path and all the intermediate directories that don't
+ exist
+
+ Might raise OSError
+
+ @param path: path to create
+ @type path: str
+ """
+ try:
+ os.makedirs(path)
+ except OSError as exc:
+ if exc.errno == errno.EEXIST and os.path.isdir(path):
+ pass
+ else:
+ raise