Added faster copy in case of rmdir

This commit is contained in:
Josh Yelon 2007-04-13 17:44:12 +00:00
parent ddf3b5c518
commit c1ec8b0fb3
1 changed files with 20 additions and 3 deletions

View File

@ -152,13 +152,30 @@ else:
#
##############################################################################
def limitedCopyTree(src, dst, rmdir):
if (os.path.isdir(src)):
if (rmdir.has_key(os.path.basename(src))):
return
os.mkdir(dst)
for x in os.listdir(src):
limitedCopyTree(os.path.join(src,x), os.path.join(dst,x), rmdir)
else:
shutil.copyfile(src, dst)
TMPDIR=os.path.abspath("packpanda-TMP")
print ""
print "Copying the game to "+TMPDIR+"..."
if (os.path.exists(TMPDIR)):
try: shutil.rmtree(TMPDIR)
except: sys.exit("Cannot delete "+TMPDIR)
try: shutil.copytree(DIR, TMPDIR)
try: shutil.rmtree(TMPDIR)
except: sys.exit("Cannot delete "+TMPDIR)
try:
rmdir = {}
for x in OPTIONS["rmdir"]:
rmdir[x] = 1
limitedCopyTree(DIR, TMPDIR, rmdir)
if not os.path.isdir( TMPDIR ):
os.mkdir(TMPDIR)
except: sys.exit("Cannot copy game to "+TMPDIR)
##############################################################################