From 4c7840d330eec01aa03289c6a4a0a9c37935d5e4 Mon Sep 17 00:00:00 2001 From: Ryan Macnak Date: Tue, 19 Apr 2022 23:27:17 +0000 Subject: [PATCH] [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 Commit-Queue: Ryan Macnak --- runtime/bin/dart_io_api_impl.cc | 13 +++++++++++++ runtime/include/bin/dart_io_api.h | 6 ++++++ 2 files changed, 19 insertions(+) diff --git a/runtime/bin/dart_io_api_impl.cc b/runtime/bin/dart_io_api_impl.cc index 8ec2c1de35e..bc0d36893a7 100644 --- a/runtime/bin/dart_io_api_impl.cc +++ b/runtime/bin/dart_io_api_impl.cc @@ -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); } diff --git a/runtime/include/bin/dart_io_api.h b/runtime/include/bin/dart_io_api.h index e194f7ae98e..cc647976c9d 100644 --- a/runtime/include/bin/dart_io_api.h +++ b/runtime/include/bin/dart_io_api.h @@ -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.