Index: experimental/PdfViewer/copy_files.py |
=================================================================== |
--- experimental/PdfViewer/copy_files.py (revision 10721) |
+++ experimental/PdfViewer/copy_files.py (working copy) |
@@ -2,8 +2,24 @@ |
import shutil |
import sys |
+def copyfile(src, dst): |
+ fsrc = None |
+ fdst = None |
+ try: |
+ fsrc = open(src, 'rb') |
+ fdst = open(dst, 'wb') |
+ shutil.copyfileobj(fsrc, fdst) |
+ finally: |
+ if fdst: |
+ fdst.close() |
+ if fsrc: |
+ fsrc.close() |
+ |
dstdir = sys.argv[1] |
+if not os.path.exists(dstdir): |
+ os.makedirs(dstdir) |
+ |
for i in range(2, len(sys.argv)): |
- shutil.copy(sys.argv[i], dstdir) |
+ copyfile(sys.argv[i], os.path.join(dstdir, os.path.basename(sys.argv[i]))) |