summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Runge <mrunge@google.com>2013-11-08 01:13:15 +0100
committerAndroid Git Automerger <android-git-automerger@android.com>2013-11-08 01:13:15 +0100
commit9690e2b370f3f303ef75e1fd5c7fdbea8787d46a (patch)
tree74551c83cecf5ad11e5291cdc3e4d77ddca59b74
parentam a370c0f7: am 3966c571: merge in klp-release (no-op) (diff)
parentam c64e76c7: Merge "Enable incremental builder to find files that moved, and try to process them via patch + rename, instead of delete + add." into klp-dev (diff)
downloadandroid_bootable_recovery-9690e2b370f3f303ef75e1fd5c7fdbea8787d46a.tar
android_bootable_recovery-9690e2b370f3f303ef75e1fd5c7fdbea8787d46a.tar.gz
android_bootable_recovery-9690e2b370f3f303ef75e1fd5c7fdbea8787d46a.tar.bz2
android_bootable_recovery-9690e2b370f3f303ef75e1fd5c7fdbea8787d46a.tar.lz
android_bootable_recovery-9690e2b370f3f303ef75e1fd5c7fdbea8787d46a.tar.xz
android_bootable_recovery-9690e2b370f3f303ef75e1fd5c7fdbea8787d46a.tar.zst
android_bootable_recovery-9690e2b370f3f303ef75e1fd5c7fdbea8787d46a.zip
Diffstat (limited to '')
-rw-r--r--updater/install.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/updater/install.c b/updater/install.c
index 061aa7b5b..6a8a6b3fc 100644
--- a/updater/install.c
+++ b/updater/install.c
@@ -285,6 +285,40 @@ done:
return StringValue(result);
}
+Value* RenameFn(const char* name, State* state, int argc, Expr* argv[]) {
+ char* result = NULL;
+ if (argc != 2) {
+ return ErrorAbort(state, "%s() expects 2 args, got %d", name, argc);
+ }
+
+ char* src_name;
+ char* dst_name;
+
+ if (ReadArgs(state, argv, 2, &src_name, &dst_name) < 0) {
+ return NULL;
+ }
+ if (strlen(src_name) == 0) {
+ ErrorAbort(state, "src_name argument to %s() can't be empty", name);
+ goto done;
+ }
+ if (strlen(dst_name) == 0) {
+ ErrorAbort(state, "dst_name argument to %s() can't be empty",
+ name);
+ goto done;
+ }
+
+ if (rename(src_name, dst_name) != 0) {
+ ErrorAbort(state, "Rename of %s() to %s() failed, error %s()",
+ src_name, dst_name, strerror(errno));
+ } else {
+ result = dst_name;
+ }
+
+done:
+ free(src_name);
+ if (result != dst_name) free(dst_name);
+ return StringValue(result);
+}
Value* DeleteFn(const char* name, State* state, int argc, Expr* argv[]) {
char** paths = malloc(argc * sizeof(char*));
@@ -1338,6 +1372,7 @@ void RegisterInstallFunctions() {
RegisterFunction("read_file", ReadFileFn);
RegisterFunction("sha1_check", Sha1CheckFn);
+ RegisterFunction("rename", RenameFn);
RegisterFunction("wipe_cache", WipeCacheFn);