From c1ec8b0fb3229b75808ff4fab218f80af6747019 Mon Sep 17 00:00:00 2001 From: Josh Yelon Date: Fri, 13 Apr 2007 17:44:12 +0000 Subject: [PATCH] Added faster copy in case of rmdir --- direct/src/directscripts/packpanda.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/direct/src/directscripts/packpanda.py b/direct/src/directscripts/packpanda.py index 9868242a88..68e4e1f8a0 100755 --- a/direct/src/directscripts/packpanda.py +++ b/direct/src/directscripts/packpanda.py @@ -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) ##############################################################################