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, Nov 5, 4:32 AM
Unknown Object (File)
Tue, Nov 5, 4:31 AM
Unknown Object (File)
Tue, Nov 5, 4:31 AM
Unknown Object (File)
Tue, Nov 5, 4:31 AM
Unknown Object (File)
Tue, Nov 5, 4:31 AM
Unknown Object (File)
Oct 31 2024, 12:05 PM
Unknown Object (File)
Oct 28 2024, 3:03 PM
Unknown Object (File)
Oct 14 2024, 5:15 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