diff options
author | Tao Bao <tbao@google.com> | 2018-07-10 21:38:22 +0200 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2018-07-10 21:38:22 +0200 |
commit | e089c1a1498027fb3397faaca9ea1a2ef9d11230 (patch) | |
tree | 38f70bda3279d9be673785cc6ddc9cedf3126155 /updater | |
parent | Merge "edify: Rename parse_string to ParseString and let it take std::string." (diff) | |
parent | Merge "updater: Let read_file() return Value::Type::STRING." (diff) | |
download | android_bootable_recovery-e089c1a1498027fb3397faaca9ea1a2ef9d11230.tar android_bootable_recovery-e089c1a1498027fb3397faaca9ea1a2ef9d11230.tar.gz android_bootable_recovery-e089c1a1498027fb3397faaca9ea1a2ef9d11230.tar.bz2 android_bootable_recovery-e089c1a1498027fb3397faaca9ea1a2ef9d11230.tar.lz android_bootable_recovery-e089c1a1498027fb3397faaca9ea1a2ef9d11230.tar.xz android_bootable_recovery-e089c1a1498027fb3397faaca9ea1a2ef9d11230.tar.zst android_bootable_recovery-e089c1a1498027fb3397faaca9ea1a2ef9d11230.zip |
Diffstat (limited to 'updater')
-rw-r--r-- | updater/install.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/updater/install.cpp b/updater/install.cpp index 75e805224..ba7bd55b0 100644 --- a/updater/install.cpp +++ b/updater/install.cpp @@ -740,7 +740,7 @@ Value* RunProgramFn(const char* name, State* state, const std::vector<std::uniqu } // read_file(filename) -// Reads a local file 'filename' and returns its contents as a Value string. +// Reads a local file 'filename' and returns its contents as a string Value. Value* ReadFileFn(const char* name, State* state, const std::vector<std::unique_ptr<Expr>>& argv) { if (argv.size() != 1) { return ErrorAbort(state, kArgsParsingFailure, "%s() expects 1 arg, got %zu", name, argv.size()); @@ -752,13 +752,13 @@ Value* ReadFileFn(const char* name, State* state, const std::vector<std::unique_ } const std::string& filename = args[0]; - FileContents fc; - if (LoadFileContents(filename.c_str(), &fc) == 0) { - return new Value(Value::Type::BLOB, std::string(fc.data.cbegin(), fc.data.cend())); + std::string contents; + if (android::base::ReadFileToString(filename, &contents)) { + return new Value(Value::Type::STRING, std::move(contents)); } // Leave it to caller to handle the failure. - LOG(ERROR) << name << ": Failed to read " << filename; + PLOG(ERROR) << name << ": Failed to read " << filename; return StringValue(""); } |