Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sandbox.filesystem.rename() #386

Open
jamesmurdza opened this issue Jun 15, 2024 · 5 comments
Open

sandbox.filesystem.rename() #386

jamesmurdza opened this issue Jun 15, 2024 · 5 comments

Comments

@jamesmurdza
Copy link

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)

@mlejva
Copy link
Member

mlejva commented Jun 15, 2024

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?

@jamesmurdza
Copy link
Author

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);
}

@ValentaTomas
Copy link
Member

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.

@ValentaTomas
Copy link
Member

@jamesmurdza Are there any other operations that you had to use a workaround for?

@jamesmurdza
Copy link
Author

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants