summaryrefslogtreecommitdiffstats
path: root/updater/install.cpp
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2016-11-18 18:55:30 +0100
committerandroid-build-merger <android-build-merger@google.com>2016-11-18 18:55:30 +0100
commit9a7618e1d1ce18b07421106ce4b35eccc444ee89 (patch)
treef7a7b85e1b2e05450204ee153521156384bdbf8d /updater/install.cpp
parentMerge "Revert "Convert update_verifier to boot HIDL HAL"" (diff)
parentMerge "updater: Add testcase for package_extract_dir()." am: 23e785935e am: d109c788ad (diff)
downloadandroid_bootable_recovery-9a7618e1d1ce18b07421106ce4b35eccc444ee89.tar
android_bootable_recovery-9a7618e1d1ce18b07421106ce4b35eccc444ee89.tar.gz
android_bootable_recovery-9a7618e1d1ce18b07421106ce4b35eccc444ee89.tar.bz2
android_bootable_recovery-9a7618e1d1ce18b07421106ce4b35eccc444ee89.tar.lz
android_bootable_recovery-9a7618e1d1ce18b07421106ce4b35eccc444ee89.tar.xz
android_bootable_recovery-9a7618e1d1ce18b07421106ce4b35eccc444ee89.tar.zst
android_bootable_recovery-9a7618e1d1ce18b07421106ce4b35eccc444ee89.zip
Diffstat (limited to 'updater/install.cpp')
-rw-r--r--updater/install.cpp38
1 files changed, 21 insertions, 17 deletions
diff --git a/updater/install.cpp b/updater/install.cpp
index da68420e8..6c110732a 100644
--- a/updater/install.cpp
+++ b/updater/install.cpp
@@ -454,28 +454,32 @@ Value* SetProgressFn(const char* name, State* state, int argc, Expr* argv[]) {
return StringValue(frac_str);
}
-// package_extract_dir(package_path, destination_path)
-Value* PackageExtractDirFn(const char* name, State* state,
- int argc, Expr* argv[]) {
- if (argc != 2) {
- return ErrorAbort(state, kArgsParsingFailure, "%s() expects 2 args, got %d", name, argc);
- }
+// package_extract_dir(package_dir, dest_dir)
+// Extracts all files from the package underneath package_dir and writes them to the
+// corresponding tree beneath dest_dir. Any existing files are overwritten.
+// Example: package_extract_dir("system", "/system")
+//
+// Note: package_dir needs to be a relative path; dest_dir needs to be an absolute path.
+Value* PackageExtractDirFn(const char* name, State* state, int argc, Expr* argv[]) {
+ if (argc != 2) {
+ return ErrorAbort(state, kArgsParsingFailure, "%s() expects 2 args, got %d", name, argc);
+ }
- std::vector<std::string> args;
- if (!ReadArgs(state, 2, argv, &args)) {
- return ErrorAbort(state, kArgsParsingFailure, "%s() Failed to parse the argument(s)", name);
- }
- const std::string& zip_path = args[0];
- const std::string& dest_path = args[1];
+ std::vector<std::string> args;
+ if (!ReadArgs(state, 2, argv, &args)) {
+ return ErrorAbort(state, kArgsParsingFailure, "%s() Failed to parse the argument(s)", name);
+ }
+ const std::string& zip_path = args[0];
+ const std::string& dest_path = args[1];
- ZipArchiveHandle za = ((UpdaterInfo*)(state->cookie))->package_zip;
+ ZipArchiveHandle za = static_cast<UpdaterInfo*>(state->cookie)->package_zip;
- // To create a consistent system image, never use the clock for timestamps.
- struct utimbuf timestamp = { 1217592000, 1217592000 }; // 8/1/2008 default
+ // To create a consistent system image, never use the clock for timestamps.
+ constexpr struct utimbuf timestamp = { 1217592000, 1217592000 }; // 8/1/2008 default
- bool success = ExtractPackageRecursive(za, zip_path, dest_path, &timestamp, sehandle);
+ bool success = ExtractPackageRecursive(za, zip_path, dest_path, &timestamp, sehandle);
- return StringValue(success ? "t" : "");
+ return StringValue(success ? "t" : "");
}
// package_extract_file(package_file[, dest_file])