[tonic] Fix Fuchsia build
TEST=ensure build works on Fuchsia
Change-Id: Idbedeaccaa40f6fa85065a42fe682d8c0c82530c
diff --git a/file_loader/file_loader_fuchsia.cc b/file_loader/file_loader_fuchsia.cc
index f117865..9e125a5 100644
--- a/file_loader/file_loader_fuchsia.cc
+++ b/file_loader/file_loader_fuchsia.cc
@@ -13,10 +13,8 @@
#include <memory>
#include <utility>
-#include "filesystem/directory.h"
#include "filesystem/file.h"
#include "filesystem/path.h"
-#include "filesystem/symlink.h"
#include "tonic/common/macros.h"
#include "tonic/converter/dart_converter.h"
#include "tonic/parsers/packages_map.h"
diff --git a/filesystem/filesystem/file.cc b/filesystem/filesystem/file.cc
index b4ac586..44dafc4 100644
--- a/filesystem/filesystem/file.cc
+++ b/filesystem/filesystem/file.cc
@@ -57,6 +57,8 @@
return true;
}
+} // namespace
+
std::pair<uint8_t*, intptr_t> ReadFileDescriptorToBytes(int fd) {
std::pair<uint8_t*, intptr_t> failure_pair{nullptr, -1};
struct stat st;
@@ -79,13 +81,15 @@
return std::pair<uint8_t*, intptr_t>(ptr, file_size);
}
-} // namespace
-
bool ReadFileToString(const std::string& path, std::string* result) {
Descriptor fd(open(path.c_str(), O_RDONLY));
return ReadFileDescriptor(fd.get(), result);
}
+bool ReadFileDescriptorToString(int fd, std::string* result) {
+ return ReadFileDescriptor(fd, result);
+}
+
std::pair<uint8_t*, intptr_t> ReadFileToBytes(const std::string& path) {
std::pair<uint8_t*, intptr_t> failure_pair{nullptr, -1};
Descriptor fd(open(path.c_str(), O_RDONLY | BINARY_MODE));
diff --git a/filesystem/filesystem/file.h b/filesystem/filesystem/file.h
index f3de866..7b85b97 100644
--- a/filesystem/filesystem/file.h
+++ b/filesystem/filesystem/file.h
@@ -42,11 +42,13 @@
// otherwise returns false. If this function returns false, |result| will be
// the empty string.
bool ReadFileToString(const std::string& path, std::string* result);
+bool ReadFileDescriptorToString(int fd, std::string* result);
// Reads the contents of the file at the given path and if successful, returns
// pair of read allocated bytes with data and size of the data if succesful.
// pair of <nullptr, -1> if read failed.
std::pair<uint8_t*, intptr_t> ReadFileToBytes(const std::string& path);
+std::pair<uint8_t*, intptr_t> ReadFileDescriptorToBytes(int fd);
} // namespace filesystem