Open jamesmurdza opened 2 weeks ago
Thanks @jamesmurdza! I think having fs.move(oldPath, newPath)
that works for both files and dirs would make sense. @ValentaTomas we could add this to the new SDK we're working on. What do youthink?
That would be great! Much better than what I'm doing now:
const moveFile = async (filesystem: FilesystemManager, filePath: string, newFilePath: string) => {
const fileContents = await filesystem.readBytes(filePath)
await filesystem.writeBytes(newFilePath, fileContents);
await filesystem.remove(filePath);
}
Sounds good — should be quick to add. I originally removed this from the new SDK proposal because I wanted to keep it minimal, but now seeing that @jamesmurdza already needs this validates it.
P.S. I think the workaround right now could be using process.startAndWait
with mv
command.
@jamesmurdza Are there any other operations that you had to use a workaround for?
@ValentaTomas Right, not sure why I'm not doing it that way now.
Yes, for the terminal SDK I'm using:
await terminal.sendData(`cd "${path}"\rclear\r`)
because
terminal.start({ ..., cwd: path })
doesn't set the working directory as expected.
However, I didn't create an issue for this because @mlejva mentioned you're already rewriting some of this.
Right now there is no method to move or rename a file or directory in a sandbox, like
fs.rename
.I would suggest adding one. For example:
rename(oldPath, newPath)