1 // Copyright 2013 The Flutter Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef FLUTTER_SHELL_PLATFORM_FUCHSIA_RUNTIME_DART_UTILS_FILES_H_ 6 #define FLUTTER_SHELL_PLATFORM_FUCHSIA_RUNTIME_DART_UTILS_FILES_H_ 7 8 #include <string> 9 10 namespace dart_utils { 11 12 // Reads the contents of the file at the given path or file descriptor and 13 // stores the data in result. Returns true if the file was read successfully, 14 // otherwise returns false. If this function returns false, |result| will be 15 // the empty string. 16 bool ReadFileToString(const std::string& path, std::string* result); 17 bool ReadFileToStringAt(int dirfd, 18 const std::string& path, 19 std::string* result); 20 21 // Writes the given data to the file at the given path. Returns true if the data 22 // was successfully written, otherwise returns false. 23 bool WriteFile(const std::string& path, const char* data, ssize_t size); 24 25 } // namespace dart_utils 26 27 #endif // FLUTTER_SHELL_PLATFORM_FUCHSIA_RUNTIME_DART_UTILS_FILES_H_ 28