summaryrefslogtreecommitdiffstats
path: root/updater/install.cpp
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2016-11-18 18:49:00 +0100
committerandroid-build-merger <android-build-merger@google.com>2016-11-18 18:49:00 +0100
commit9b1a791e3c16e8fc857f359796e8984a28a8c754 (patch)
tree52eea029d9ba1bfa3a44dd876621bcda11ffbce6 /updater/install.cpp
parentMerge "applypatch: Use unique_fd to avoid leaking FDs." am: 2e5cf3c0bc (diff)
parentMerge "updater: Add testcase for package_extract_dir()." (diff)
downloadandroid_bootable_recovery-9b1a791e3c16e8fc857f359796e8984a28a8c754.tar
android_bootable_recovery-9b1a791e3c16e8fc857f359796e8984a28a8c754.tar.gz
android_bootable_recovery-9b1a791e3c16e8fc857f359796e8984a28a8c754.tar.bz2
android_bootable_recovery-9b1a791e3c16e8fc857f359796e8984a28a8c754.tar.lz
android_bootable_recovery-9b1a791e3c16e8fc857f359796e8984a28a8c754.tar.xz
android_bootable_recovery-9b1a791e3c16e8fc857f359796e8984a28a8c754.tar.zst
android_bootable_recovery-9b1a791e3c16e8fc857f359796e8984a28a8c754.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])