webr icon indicating copy to clipboard operation
webr copied to clipboard

Rename feature for filesystem

Open Dual-Ice opened this issue 9 months ago • 0 comments

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.

Dual-Ice avatar Jan 22 '25 10:01 Dual-Ice