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

Rename feature for filesystem #509

Open
Dual-Ice opened this issue Jan 22, 2025 · 0 comments
Open

Rename feature for filesystem #509

Dual-Ice opened this issue Jan 22, 2025 · 0 comments
Labels
feature New feature or request

Comments

@Dual-Ice
Copy link

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.

@georgestagg georgestagg added the feature New feature or request label Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants