From 2e6e053981667bebfcb43ef0815f4a4323faf06c Mon Sep 17 00:00:00 2001 From: Jason San Jose Date: Mon, 10 Dec 2012 17:57:55 -0800 Subject: [PATCH] rename back to copyPath() --- .../default/JavaScriptQuickEdit/unittests.js | 2 +- test/spec/InlineEditorProviders-test.js | 2 +- test/spec/LowLevelFileIO-test.js | 2 +- test/spec/NativeFileSystem-test.js | 2 +- test/spec/SpecRunnerUtils.js | 44 ++++++------------- 5 files changed, 18 insertions(+), 34 deletions(-) diff --git a/src/extensions/default/JavaScriptQuickEdit/unittests.js b/src/extensions/default/JavaScriptQuickEdit/unittests.js index f62e9c1be22..c646009092c 100644 --- a/src/extensions/default/JavaScriptQuickEdit/unittests.js +++ b/src/extensions/default/JavaScriptQuickEdit/unittests.js @@ -54,7 +54,7 @@ define(function (require, exports, module) { removePrefix : true }; - SpecRunnerUtils.copyDirectoryPath(testPath, tempPath, options).done(function () { + SpecRunnerUtils.copyPath(testPath, tempPath, options).done(function () { spec.infos = infos; result.resolve(); }).fail(function () { diff --git a/test/spec/InlineEditorProviders-test.js b/test/spec/InlineEditorProviders-test.js index 71302a10b67..ac06f0935b2 100644 --- a/test/spec/InlineEditorProviders-test.js +++ b/test/spec/InlineEditorProviders-test.js @@ -58,7 +58,7 @@ define(function (require, exports, module) { removePrefix : true }; - SpecRunnerUtils.copyDirectoryPath(testPath, tempPath, options).done(function () { + SpecRunnerUtils.copyPath(testPath, tempPath, options).done(function () { spec.infos = infos; result.resolve(); }).fail(function () { diff --git a/test/spec/LowLevelFileIO-test.js b/test/spec/LowLevelFileIO-test.js index a204ec1fc16..cfcb5761883 100644 --- a/test/spec/LowLevelFileIO-test.js +++ b/test/spec/LowLevelFileIO-test.js @@ -44,7 +44,7 @@ define(function (require, exports, module) { beforeEach(function () { runs(function () { var testFiles = SpecRunnerUtils.getTestPath("/spec/LowLevelFileIO-test-files"); - waitsForDone(SpecRunnerUtils.copyDirectoryPath(testFiles, baseDir)); + waitsForDone(SpecRunnerUtils.copyPath(testFiles, baseDir)); }); runs(function () { diff --git a/test/spec/NativeFileSystem-test.js b/test/spec/NativeFileSystem-test.js index f04bc75f683..5cf4662082b 100644 --- a/test/spec/NativeFileSystem-test.js +++ b/test/spec/NativeFileSystem-test.js @@ -47,7 +47,7 @@ define(function (require, exports, module) { runs(function () { var testFiles = SpecRunnerUtils.getTestPath("/spec/NativeFileSystem-test-files"); self.path = SpecRunnerUtils.getTempDirectory(); - waitsForDone(SpecRunnerUtils.copyDirectoryPath(testFiles, self.path)); + waitsForDone(SpecRunnerUtils.copyPath(testFiles, self.path)); }); runs(function () { diff --git a/test/spec/SpecRunnerUtils.js b/test/spec/SpecRunnerUtils.js index 0f02fee4571..d2f02ccf677 100644 --- a/test/spec/SpecRunnerUtils.js +++ b/test/spec/SpecRunnerUtils.js @@ -542,29 +542,6 @@ define(function (require, exports, module) { return deferred.promise(); } - /** - * Copy a file source path to a destination - * @param {!string} source Path for the source file to copy - * @param {!string} destination Destination path to copy the source file - * @param {?{parseOffsets:boolean}} options parseOffsets allows optional - * offset markup parsing. File is written to the destination path - * without offsets. Offset data is passed to the doneCallbacks of the - * promise. - * @return {$.Promise} A promise resolved when the file is copied to the - * destination. - */ - function copyFilePath(source, destination, options) { - var deferred = new $.Deferred(); - - resolveNativeFileSystemPath(source).done(function (entry) { - copyFileEntry(entry, destination, options).pipe(deferred.resolve, deferred.reject); - }).fail(function () { - deferred.reject(); - }); - - return deferred.promise(); - } - /** * Copy a directory source to a destination * @param {!DirectoryEntry} source Entry for the source directory to copy @@ -651,9 +628,9 @@ define(function (require, exports, module) { } /** - * Copy a directory source path to a destination - * @param {!string} source Path for the source directory to copy - * @param {!string} destination Destination path to copy the source directory + * Copy a file or directory source path to a destination + * @param {!string} source Path for the source file or directory to copy + * @param {!string} destination Destination path to copy the source file or directory * @param {?{parseOffsets:boolean, infos:Object, removePrefix:boolean}}} options * parseOffsets - allows optional offset markup parsing. File is written to the * destination path without offsets. Offset data is passed to the @@ -667,11 +644,19 @@ define(function (require, exports, module) { * contents are copied to the destination or rejected immediately * upon the first error. */ - function copyDirectoryPath(source, destination, options) { + function copyPath(source, destination, options) { var deferred = new $.Deferred(); resolveNativeFileSystemPath(source).done(function (entry) { - copyDirectoryEntry(entry, destination, options).pipe(deferred.resolve, deferred.reject); + var promise; + + if (entry.isDirectory) { + promise = copyDirectoryEntry(entry, destination, options); + } else { + promise = copyFileEntry(entry, destination, options); + } + + promise.pipe(deferred.resolve, deferred.reject); }).fail(function () { deferred.reject(); }); @@ -823,9 +808,8 @@ define(function (require, exports, module) { exports.toggleQuickEditAtOffset = toggleQuickEditAtOffset; exports.createTextFile = createTextFile; exports.copyDirectoryEntry = copyDirectoryEntry; - exports.copyDirectoryPath = copyDirectoryPath; exports.copyFileEntry = copyFileEntry; - exports.copyFilePath = copyFilePath; + exports.copyPath = copyPath; exports.deletePath = deletePath; exports.getTestWindow = getTestWindow; exports.simulateKeyEvent = simulateKeyEvent;