Create tar directory when making build set tar files.

Move the mkdir and removeall code from the build module to the path
module.
This commit is contained in:
Chris Johns
2013-02-22 14:44:51 +11:00
parent cafbcc611b
commit ee47d7210e
3 changed files with 41 additions and 31 deletions

View File

@@ -24,8 +24,11 @@
#
import os
import shutil
import string
import error
windows = os.name == 'nt'
def host(path):
@@ -81,6 +84,36 @@ def isfile(path):
def isabspath(path):
return path[0] == '/'
def mkdir(path):
if exists(path):
if not isdir(path):
raise error.general('path exists and is not a directory: %s' % (path))
else:
if windows:
try:
os.makedirs(host(path))
except IOError, err:
raise error.general('cannot make directory: %s' % (path))
except OSError, err:
raise error.general('cannot make directory: %s' % (path))
except WindowsError, err:
raise error.general('cannot make directory: %s' % (path))
else:
try:
os.makedirs(host(path))
except IOError, err:
raise error.general('cannot make directory: %s' % (path))
except OSError, err:
raise error.general('cannot make directory: %s' % (path))
def removeall(path):
def _onerror(function, path, excinfo):
print 'removeall error: (%r) %s' % (function, path)
shutil.rmtree(path, onerror = _onerror)
return
if __name__ == '__main__':
print host('/a/b/c/d-e-f')
print host('//a/b//c/d-e-f')