mirror of
https://git.rtems.org/rtems-source-builder
synced 2024-10-09 07:15:10 +08:00
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:
@@ -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')
|
||||
|
Reference in New Issue
Block a user