diff options
author | Tao Bao <tbao@google.com> | 2018-07-10 18:34:56 +0200 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2018-07-10 18:34:56 +0200 |
commit | 503ff38043fc333800bbaa56bb5be66656c2cdae (patch) | |
tree | 25e167440b5c06697a6b91640afd71be2fd965a6 /updater/install.cpp | |
parent | Merge "applypatch: Restrict applypatch_check to eMMC targets." (diff) | |
parent | edify: Remove VAL_INVALID and move ValueType into Value class. (diff) | |
download | android_bootable_recovery-503ff38043fc333800bbaa56bb5be66656c2cdae.tar android_bootable_recovery-503ff38043fc333800bbaa56bb5be66656c2cdae.tar.gz android_bootable_recovery-503ff38043fc333800bbaa56bb5be66656c2cdae.tar.bz2 android_bootable_recovery-503ff38043fc333800bbaa56bb5be66656c2cdae.tar.lz android_bootable_recovery-503ff38043fc333800bbaa56bb5be66656c2cdae.tar.xz android_bootable_recovery-503ff38043fc333800bbaa56bb5be66656c2cdae.tar.zst android_bootable_recovery-503ff38043fc333800bbaa56bb5be66656c2cdae.zip |
Diffstat (limited to 'updater/install.cpp')
-rw-r--r-- | updater/install.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/updater/install.cpp b/updater/install.cpp index 9d108e0ed..02a6fe7c5 100644 --- a/updater/install.cpp +++ b/updater/install.cpp @@ -191,7 +191,7 @@ Value* PackageExtractFileFn(const char* name, State* state, zip_path.c_str(), buffer.size(), ErrorCodeString(ret)); } - return new Value(VAL_BLOB, buffer); + return new Value(Value::Type::BLOB, buffer); } } @@ -238,10 +238,10 @@ Value* ApplyPatchFn(const char* name, State* state, } for (int i = 0; i < patchcount; ++i) { - if (arg_values[i * 2]->type != VAL_STRING) { + if (arg_values[i * 2]->type != Value::Type::STRING) { return ErrorAbort(state, kArgsParsingFailure, "%s(): sha-1 #%d is not string", name, i * 2); } - if (arg_values[i * 2 + 1]->type != VAL_BLOB) { + if (arg_values[i * 2 + 1]->type != Value::Type::BLOB) { return ErrorAbort(state, kArgsParsingFailure, "%s(): patch #%d is not blob", name, i * 2 + 1); } } @@ -741,8 +741,8 @@ Value* RunProgramFn(const char* name, State* state, const std::vector<std::uniqu return StringValue(std::to_string(status)); } -// Read a local file and return its contents (the Value* returned -// is actually a FileContents*). +// read_file(filename) +// Reads a local file 'filename' and returns its contents as a Value string. 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()); @@ -750,18 +750,18 @@ Value* ReadFileFn(const char* name, State* state, const std::vector<std::unique_ std::vector<std::string> args; if (!ReadArgs(state, argv, &args)) { - return ErrorAbort(state, kArgsParsingFailure, "%s() Failed to parse the argument(s)", name); + return ErrorAbort(state, kArgsParsingFailure, "%s(): Failed to parse the argument(s)", name); } const std::string& filename = args[0]; - Value* v = new Value(VAL_INVALID, ""); - FileContents fc; if (LoadFileContents(filename.c_str(), &fc) == 0) { - v->type = VAL_BLOB; - v->data = std::string(fc.data.begin(), fc.data.end()); + return new Value(Value::Type::BLOB, std::string(fc.data.cbegin(), fc.data.cend())); } - return v; + + // Leave it to caller to handle the failure. + LOG(ERROR) << name << ": Failed to read " << filename; + return StringValue(""); } // write_value(value, filename) |