Csound Csound-dev Csound-tekno Search About

[Csnd] WASM fs oddities

Date2024-11-21 00:23
FromRichard Knight
Subject[Csnd] WASM fs oddities

I have observed a couple of strange behaviours in the fs functions of the latest WASM build (https://www.npmjs.com/package/@csound/browser) - assuming I'm using them right - does anyone know about these or have any suggestions on how to work around?

Basically it seems like files can't be unlinked, and creating a file in an attempt to overwrite it results in a duplicate, with the same name. Incidentally file appending works ok, so it seems existing data may not be modified:

// appearance of duplicate files when writing same path
for (var x = 0; x < 6; x++) csound.fs.writeFile("/test", new Uint8Array([99 + x]));
console.log(await csound.fs.readdir("/"));
// ["test", "test", "test", "test", "test", "test"]

// unlink doesn't appear to work
let file = "/deleteme";
csound.fs.writeFile(file, new Uint8Array([0]));
csound.fs.unlink(file);
console.log(await csound.fs.readdir("/"));
// ["deleteme"]


Date2024-11-21 00:28
FromRichard Knight
SubjectRe: [Csnd] WASM fs oddities

I missed the awaits on the writeFile and unlink calls in the example - but it has the same result.

 


On 2024-11-21 00:23, Richard Knight wrote:

I have observed a couple of strange behaviours in the fs functions of the latest WASM build (https://www.npmjs.com/package/@csound/browser) - assuming I'm using them right - does anyone know about these or have any suggestions on how to work around?

Basically it seems like files can't be unlinked, and creating a file in an attempt to overwrite it results in a duplicate, with the same name. Incidentally file appending works ok, so it seems existing data may not be modified:

// appearance of duplicate files when writing same path
for (var x = 0; x < 6; x++) csound.fs.writeFile("/test", new Uint8Array([99 + x]));
console.log(await csound.fs.readdir("/"));
// ["test", "test", "test", "test", "test", "test"]

// unlink doesn't appear to work
let file = "/deleteme";
csound.fs.writeFile(file, new Uint8Array([0]));
csound.fs.unlink(file);
console.log(await csound.fs.readdir("/"));
// ["deleteme"]

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2024-11-21 06:04
FromHlöðver Sigurðsson
SubjectRe: [Csnd] WASM fs oddities
it sounds like you found a bug, the unlink is probably a rare use-case and I may have missed out a bug when developing this fs module, please open a ticket so I don't forget about this

On Thu, 21 Nov 2024 at 02:28, Richard Knight <richard@1bpm.net> wrote:

I missed the awaits on the writeFile and unlink calls in the example - but it has the same result.

 


On 2024-11-21 00:23, Richard Knight wrote:

I have observed a couple of strange behaviours in the fs functions of the latest WASM build (https://www.npmjs.com/package/@csound/browser) - assuming I'm using them right - does anyone know about these or have any suggestions on how to work around?

Basically it seems like files can't be unlinked, and creating a file in an attempt to overwrite it results in a duplicate, with the same name. Incidentally file appending works ok, so it seems existing data may not be modified:

// appearance of duplicate files when writing same path
for (var x = 0; x < 6; x++) csound.fs.writeFile("/test", new Uint8Array([99 + x]));
console.log(await csound.fs.readdir("/"));
// ["test", "test", "test", "test", "test", "test"]

// unlink doesn't appear to work
let file = "/deleteme";
csound.fs.writeFile(file, new Uint8Array([0]));
csound.fs.unlink(file);
console.log(await csound.fs.readdir("/"));
// ["deleteme"]

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2024-11-21 14:41
FromRichard Knight
SubjectRe: [Csnd] WASM fs oddities

OK, thanks - does the ticket need to go on the main csound/csound repository or somewhere else?

 


On 2024-11-21 06:04, Hlöðver Sigurðsson wrote:

it sounds like you found a bug, the unlink is probably a rare use-case and I may have missed out a bug when developing this fs module, please open a ticket so I don't forget about this

On Thu, 21 Nov 2024 at 02:28, Richard Knight <richard@1bpm.net> wrote:

I missed the awaits on the writeFile and unlink calls in the example - but it has the same result.

 


On 2024-11-21 00:23, Richard Knight wrote:

I have observed a couple of strange behaviours in the fs functions of the latest WASM build (https://www.npmjs.com/package/@csound/browser) - assuming I'm using them right - does anyone know about these or have any suggestions on how to work around?

Basically it seems like files can't be unlinked, and creating a file in an attempt to overwrite it results in a duplicate, with the same name. Incidentally file appending works ok, so it seems existing data may not be modified:

// appearance of duplicate files when writing same path
for (var x = 0; x < 6; x++) csound.fs.writeFile("/test", new Uint8Array([99 + x]));
console.log(await csound.fs.readdir("/"));
// ["test", "test", "test", "test", "test", "test"]

// unlink doesn't appear to work
let file = "/deleteme";
csound.fs.writeFile(file, new Uint8Array([0]));
csound.fs.unlink(file);
console.log(await csound.fs.readdir("/"));
// ["deleteme"]

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here