Page MenuHomePhabricator

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

Authored by bartek on Apr 18 2023, 8:07 AM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Oct 1, 1:03 PM
Unknown Object (File)
Tue, Oct 1, 1:03 PM
Unknown Object (File)
Tue, Oct 1, 1:03 PM
Unknown Object (File)
Tue, Oct 1, 1:02 PM
Unknown Object (File)
Tue, Oct 1, 12:58 PM
Unknown Object (File)
Fri, Sep 27, 1:20 AM
Unknown Object (File)
Aug 27 2024, 5:09 AM
Unknown Object (File)
Aug 19 2024, 5:08 AM
Subscribers

Details

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]

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

bartek held this revision as a draft.
bartek published this revision for review.Apr 18 2023, 8:31 AM
kamil added inline comments.
native/cpp/CommonCpp/NativeModules/CommUtilsModule.cpp
4 ↗(On Diff #25268)

I think you should add some more includes here, eg. #include <string>. see this.

This revision is now accepted and ready to land.Apr 19 2023, 12:08 PM

Apply review feedback. Rebase before landing