summaryrefslogtreecommitdiffstats
path: root/updater/install.cpp
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2016-11-18 07:49:56 +0100
committerTao Bao <tbao@google.com>2016-11-18 08:02:13 +0100
commit1036d36542c452b8df0200d13029d172646a2719 (patch)
tree687864a9f90e4cdfbb06d5c3abeb48ef76375952 /updater/install.cpp
parentMerge "applypatch: Use unique_fd to avoid leaking FDs." (diff)
downloadandroid_bootable_recovery-1036d36542c452b8df0200d13029d172646a2719.tar
android_bootable_recovery-1036d36542c452b8df0200d13029d172646a2719.tar.gz
android_bootable_recovery-1036d36542c452b8df0200d13029d172646a2719.tar.bz2
android_bootable_recovery-1036d36542c452b8df0200d13029d172646a2719.tar.lz
android_bootable_recovery-1036d36542c452b8df0200d13029d172646a2719.tar.xz
android_bootable_recovery-1036d36542c452b8df0200d13029d172646a2719.tar.zst
android_bootable_recovery-1036d36542c452b8df0200d13029d172646a2719.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])