home *** CD-ROM | disk | FTP | other *** search
- // Copyright 1999 Macromedia, Inc. All rights reserved.
-
- //*************** GLOBALS *****************
-
- var COPYALL = false;
- var OVERWRITE = false;
-
- var WAS_COPIED = false;
-
- var IGNORE_LOCKED = false;
-
-
- //******************* API **********************
-
- //***************** LOCAL FUNCTIONS ******************
-
- //Copies a directory and all subdirectories and files to another
- // directory. Args:
- //theSrcDirectory - the OS directory name to copy.
- //theTgtDirectory - the OS directory name to copy to.
- //
- function copyFileTree(theSrcDirectory, theTgtDirectory, dirOnly, overwrite) {
- var iFile, iDir, fileList, dirList;
- var source, target, fromFile, toFile;
- var response;
-
- source = new File(theSrcDirectory);
- target = new File(theTgtDirectory);
-
- // create the target folder
- if (!target.exists()) target.mkdir();
-
- if (!dirOnly) {
- // get a list of all the files in the source directory
- fileList = source.list("*.*");
-
- // copy all the files from the source to target directory
- fromFile = new File("");
- toFile = new File("");
- for (iFile=0; iFile < fileList.length; ++iFile) {
- toFile.setPath(target.getAbsolutePath() + FILE_sep + fileList[iFile]);
- fromFile.setPath(source.getAbsolutePath() + FILE_sep + fileList[iFile]);
- if (!toFile.exists()) {
- fromFile.copyTo(toFile.getAbsolutePath());
- } else if (overwrite) {
- if (toFile.remove())
- fromFile.copyTo(toFile.getAbsolutePath());
- else if (!IGNORE_LOCKED) {
- response = confirmCustom(errMsg(MSG_cantRemoveFile, toFile.getAbsolutePath()),LABEL_yesAll, LABEL_yes, LABEL_cancel);
- if (response == LABEL_yesAll)
- IGNORE_LOCKED = true;
- else if (response == LABEL_cancel)
- return false;
- } } }
- }
-
- // get a list of all the directories in the source directory
- dirList = source.list("*.*", "dirs");
-
- // create the target directory and copy the underlying tree
- for (iDir=0; iDir < dirList.length; ++iDir) {
- if (!copyFileTree(source.getAbsolutePath() + FILE_sep + dirList[iDir],
- target.getAbsolutePath() + FILE_sep + dirList[iDir],
- dirOnly, overwrite))
- return false;
- }
- return true;
- }
-
-
- function copyFiles() {
- var theScripts = new File(PREF_scriptsUrl);
- var theImages = new File(PREF_imagesUrl);
- if (COPYALL) {
- if (copyFileTree(FILE_scriptsUrl, PREF_scriptsUrl, false, true))
- copyFileTree(FILE_imagesUrl, PREF_imagesUrl, false, OVERWRITE);
- } else {
- copyFileTree(FILE_scriptsUrl, PREF_scriptsUrl, false, true);
- }
- }
-
-
- function initializeUI() {
-
- if (documentSaved(true))
- copyFiles();
- garbageCollect(true);
- window.close();
- }
-