HomePhabricator
Diffusion Comm 39a21ca69247

[native][utils-module] Implement file r/w operations

Description

[native][utils-module] Implement file r/w operations

Summary:
Part of ENG-3408.

This diff implements asynchronous functions to read/write file from/to ArrayBuffer.

Depends on D7452

Test Plan:
In the native JS code (e.g. root.react.js):

const myArray = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
const dir = temporaryDirectoryPath;
console.log('temp dir:', dir);
await commUtilsModule.writeBufferToFile(dir + 'temp.dat', myArray.buffer);
commUtilsModule.readBufferFromFile(dir + 'temp.dat').then(data => {
  console.log('read:', new Uint8Array(data));
});

The read value should be the same as initial array. Also checked existence of the file
For iOS:

  • open [printed temp dir path] - check if file exists
  • xxd [printed temp dir path]/temp.dat - checked if hex is equal to 01 02 ... 0a (myArray)

For Android:

  • adb root && adb pull [temp dir]/temp.dat - then xxd that file
  • adb shell su ; ls [temp dir]

Reviewers: marcin, kamil, inka

Reviewed By: kamil

Subscribers: ashoat, tomek, atul

Differential Revision: https://phab.comm.dev/D7485

Details

Provenance
bartekAuthored on Apr 18 2023, 2:55 AM
Reviewer
kamil
Differential Revision
D7485: [native][utils-module] Implement file r/w operations
Parents
rCOMM4859024da48d: [native] Install CommUtils JSI module
Branches
Unknown
Tags
Unknown