Closed Bug 1457283 Opened 7 years ago Closed 3 years ago

OS.File should provide an API to read a file into an existing buffer

Categories

(Toolkit Graveyard :: OS.File, enhancement)

enhancement
Not set
normal

Tracking

(firefox61 affected)

RESOLVED WORKSFORME
Tracking Status
firefox61 --- affected

People

(Reporter: mstange, Unassigned)

Details

I would like to process a large file in WASM code, in a worker which has chrome privileges and can use OS.File. At the moment, I have two choices to get the file's contents into WASM memory: 1. I can ask OS.File to read the entire file, which gives me a typed array, and then I can copy copy that typed array's contents into the WASM memory buffer. This consumes 2x the file size in memory at one point. 2. I can ask OS.File to read a chunk of the file, and then copy that chunk into WASM memory. I can do that in a loop until I've read the entire file. This consumes the file size + the chunk size in memory. Ideally, OS.File would let me read the file right into WASM memory. Then I'd do the following: 1. Get the size of the file and allocate space in WASM memory of that size. 2. Ask OS.File to read the file into that allocation, by giving it the WASM memory ArrayBuffer and the location of the allocation.

:mstange, do you still need this functionality? Or does IOUtils.openFileForSyncReading / SyncReadFile fit the bill?

Flags: needinfo?(mstange.moz)

SyncReadFile fits the bill, it provides everything I need. Thanks!

Status: NEW → RESOLVED
Closed: 3 years ago
Flags: needinfo?(mstange.moz)
Resolution: --- → WORKSFORME
Product: Toolkit → Toolkit Graveyard
You need to log in before you can comment on or make changes to this bug.