[dart:io] Publish implementations of the VM file callbacks.

TEST=ci
Change-Id: I481b6fe3e7eae02ff7f2c94fa2f60bef0a972b3c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241685
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
Ryan Macnak 2022-04-19 23:27:17 +00:00 committed by Commit Bot
parent 907f7dd4ae
commit 4c7840d330
2 changed files with 19 additions and 0 deletions

View file

@ -57,6 +57,19 @@ void GetIOEmbedderInformation(Dart_EmbedderInformation* info) {
Process::GetRSSInformation(&(info->max_rss), &(info->current_rss));
}
void* OpenFile(const char* name, bool write) {
return DartUtils::OpenFile(name, write);
}
void ReadFile(uint8_t** data, intptr_t* file_len, void* stream) {
DartUtils::ReadFile(data, file_len, stream);
}
void WriteFile(const void* buffer, intptr_t num_bytes, void* stream) {
DartUtils::WriteFile(buffer, num_bytes, stream);
}
void CloseFile(void* stream) {
DartUtils::CloseFile(stream);
}
bool GetEntropy(uint8_t* buffer, intptr_t length) {
return Crypto::GetRandomBytes(length, buffer);
}

View file

@ -41,6 +41,12 @@ void SetExecutableArguments(int script_index, char** argv);
// Set dart:io implementation specific fields of Dart_EmbedderInformation.
void GetIOEmbedderInformation(Dart_EmbedderInformation* info);
// Appropriate to assign to Dart_InitializeParams.file_open/read/write/close.
void* OpenFile(const char* name, bool write);
void ReadFile(uint8_t** data, intptr_t* file_len, void* stream);
void WriteFile(const void* buffer, intptr_t num_bytes, void* stream);
void CloseFile(void* stream);
// Generates 'length' random bytes into 'buffer'. Returns true on success
// and false on failure. This is appropriate to assign to
// Dart_InitializeParams.entropy_source.