Commit 1fae89cb authored by topjohnwu's avatar topjohnwu

Add new cpio command: "exists", to magiskboot

parent 8b400879
...@@ -39,6 +39,8 @@ static void usage(char *arg0) { ...@@ -39,6 +39,8 @@ static void usage(char *arg0) {
" Do cpio commands to <incpio> (modifications are done directly)\n" " Do cpio commands to <incpio> (modifications are done directly)\n"
" Each command is a single argument, use quotes if necessary\n" " Each command is a single argument, use quotes if necessary\n"
" Supported commands:\n" " Supported commands:\n"
" exists ENTRY\n"
" Return 0 if ENTRY exists, else return 1\n"
" rm [-r] ENTRY\n" " rm [-r] ENTRY\n"
" Remove ENTRY, specify [-r] to remove recursively\n" " Remove ENTRY, specify [-r] to remove recursively\n"
" mkdir MODE ENTRY\n" " mkdir MODE ENTRY\n"
......
...@@ -230,7 +230,9 @@ int cpio_commands(int argc, char *argv[]) { ...@@ -230,7 +230,9 @@ int cpio_commands(int argc, char *argv[]) {
char *sha1 = cpio.sha1(); char *sha1 = cpio.sha1();
if (sha1) printf("%s\n", sha1); if (sha1) printf("%s\n", sha1);
return 0; return 0;
} else if (cmdc >= 2 && strcmp(cmdv[0], "backup") == 0) { } else if (cmdc == 2 && strcmp(cmdv[0], "exists") == 0) {
exit(cpio.find(cmdv[1]) < 0);
} else if (cmdc == 2 && strcmp(cmdv[0], "backup") == 0) {
cpio.backup(cmdv[1]); cpio.backup(cmdv[1]);
} else if (cmdc >= 2 && strcmp(cmdv[0], "rm") == 0) { } else if (cmdc >= 2 && strcmp(cmdv[0], "rm") == 0) {
bool r = cmdc > 2 && strcmp(cmdv[1], "-r") == 0; bool r = cmdc > 2 && strcmp(cmdv[1], "-r") == 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment