webr
webr copied to clipboard
Rename feature for filesystem
Hello! Could you provide rename from https://emscripten.org/docs/api_reference/Filesystem-API.html#FS.rename May be It will be easier for you than do it
public async renameFile(oldPath: string, newPath: string) {
try {
const fileData = await this.webr.FS.readFile(oldPath);
await this.webr.FS.writeFile((newPath, fileData);
await this.webr.FS.unlink(oldPath);
} catch (e) {
if (e instanceof WebrError) {
throw new Error(`Unable to rename file: "${oldPath}".`);
}
Logger.$error(e);
}
}
for me.