mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 10:07:19 +00:00
$tw.utils.copyDirectory: Ensure directories don't overlap
This commit is contained in:
parent
ad575efdcc
commit
13b8281f6b
@ -36,8 +36,12 @@ Recursively (and synchronously) copy a directory and all its content
|
||||
*/
|
||||
exports.copyDirectory = function(srcPath,dstPath) {
|
||||
// Remove any trailing path separators
|
||||
srcPath = $tw.utils.removeTrailingSeparator(srcPath);
|
||||
dstPath = $tw.utils.removeTrailingSeparator(dstPath);
|
||||
srcPath = path.resolve($tw.utils.removeTrailingSeparator(srcPath));
|
||||
dstPath = path.resolve($tw.utils.removeTrailingSeparator(dstPath));
|
||||
// Check that neither director is within the other
|
||||
if(srcPath.substring(0,dstPath.length) === dstPath || dstPath.substring(0,srcPath.length) === srcPath) {
|
||||
return "Cannot copy nested directories";
|
||||
}
|
||||
// Create the destination directory
|
||||
var err = $tw.utils.createDirectory(dstPath);
|
||||
if(err) {
|
||||
|
Loading…
Reference in New Issue
Block a user