Hello there. I was recently working on a game which is supposed to be a "DDLC" wannabe, where files from inside the game are getting edited/copied/removed.
I'm currently trying to figure out how to copy a whole folder to another folder from inside the game' directory.
I have managed to simply copy files from a folder to another folder, yet I couldn't do the same with folders.
I have tried to use different kind of functions and scripts for basic NodeJS, yet it didn't work.
More precisely, I have tried some scripts / functions from NodeJS community to accomplish this folder copy:
Using both Path and FS modules:
Generated error: error: EEXIST: file already exists, mkdir '[censoredComputerPath]\save'
Using shell command:
Generated error: exec error: Error: Command failed: copy -r save img
Also I haven't tried the FS-EXTRA module as I don't know how to add it easily to the project.
For starters I have tried to copy the save folder within the img folder of the game director, but none of these functions didn't work.
I have ran these codes within simple common events with Script command.
Can someone please help me with this issue?
I'm currently trying to figure out how to copy a whole folder to another folder from inside the game' directory.
I have managed to simply copy files from a folder to another folder, yet I couldn't do the same with folders.
I have tried to use different kind of functions and scripts for basic NodeJS, yet it didn't work.
More precisely, I have tried some scripts / functions from NodeJS community to accomplish this folder copy:
Using both Path and FS modules:
Code:
var fs=require("fs"),path=require("path");
function copyFolderSync(from, to) {
fs.mkdirSync(to);
fs.readdirSync(from).forEach(element => {
if (fs.lstatSync(path.join(from, element)).isFile()) {
fs.copyFileSync(path.join(from, element), path.join(to, element));
} else {
copyFolderSync(path.join(from, element), path.join(to, element));
}
});
};
currentLoc = process.cwd(); copyFolderSync(currentLoc + '\\img\\', currentLoc + '\\save\\');
Using shell command:
Code:
var sys = require('sys'),
exec = require('child_process').exec;
child = exec("copy -r save img", function(error, stdout, stderr) {
sys.print("stdout: " + stdout);
sys.print("stderr: " + stderr);
if(error !== null) {
console.log("exec error: " + error);
} else {
}
});
Also I haven't tried the FS-EXTRA module as I don't know how to add it easily to the project.
For starters I have tried to copy the save folder within the img folder of the game director, but none of these functions didn't work.
I have ran these codes within simple common events with Script command.
Can someone please help me with this issue?