summaryrefslogtreecommitdiffstats
path: root/adb/commandline.c
diff options
context:
space:
mode:
authorLajos Molnar <lajos@google.com>2013-04-19 12:41:09 -0700
committerLajos Molnar <lajos@google.com>2014-05-02 11:01:38 -0700
commitde8ff4adcaa487259f9ddcd0eab4d1117d1cca71 (patch)
tree999dd713b98275ed5d184981244364e6210df98b /adb/commandline.c
parentb8f86480a28b8a57628383a49d7fc63a4f1d5971 (diff)
downloadsystem_core-de8ff4adcaa487259f9ddcd0eab4d1117d1cca71.zip
system_core-de8ff4adcaa487259f9ddcd0eab4d1117d1cca71.tar.gz
system_core-de8ff4adcaa487259f9ddcd0eab4d1117d1cca71.tar.bz2
adb: added support for adb pull -a to preserve time stamps and mode
Added -a flag to adb pull that preserves time and mode. Mode is subjected to umask for security. We only receive modification time from adb server, so creation time will be set to the modification time as well. Change-Id: I37c0b94741ed464f19025d25dea3ff2f6ac43e7f Signed-off-by: Lajos Molnar <lajos@google.com>
Diffstat (limited to 'adb/commandline.c')
-rw-r--r--adb/commandline.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/adb/commandline.c b/adb/commandline.c
index e0345a8..5df5796 100644
--- a/adb/commandline.c
+++ b/adb/commandline.c
@@ -110,9 +110,10 @@ void help()
" adb push [-p] <local> <remote>\n"
" - copy file/dir to device\n"
" ('-p' to display the transfer progress)\n"
- " adb pull [-p] <remote> [<local>]\n"
+ " adb pull [-p] [-a] <remote> [<local>]\n"
" - copy file/dir from device\n"
" ('-p' to display the transfer progress)\n"
+ " ('-a' means copy timestamp and mode)\n"
" adb sync [ <directory> ] - copy host->device only if changed\n"
" (-l means list but don't copy)\n"
" (see 'adb help all')\n"
@@ -927,12 +928,19 @@ static const char *find_product_out_path(const char *hint)
}
-static void parse_push_pull_args(char** arg, int narg, char const** path1, char const** path2,
- int* show_progress) {
+static void parse_push_pull_args(char **arg, int narg, char const **path1, char const **path2,
+ int *show_progress, int *copy_attrs) {
*show_progress = 0;
+ *copy_attrs = 0;
- if ((narg > 0) && !strcmp(*arg, "-p")) {
- *show_progress = 1;
+ while (narg > 0) {
+ if (!strcmp(*arg, "-p")) {
+ *show_progress = 1;
+ } else if (!strcmp(*arg, "-a")) {
+ *copy_attrs = 1;
+ } else {
+ break;
+ }
++arg;
--narg;
}
@@ -1396,9 +1404,10 @@ top:
if(!strcmp(argv[0], "push")) {
int show_progress = 0;
+ int copy_attrs = 0; // unused
const char* lpath = NULL, *rpath = NULL;
- parse_push_pull_args(&argv[1], argc - 1, &lpath, &rpath, &show_progress);
+ parse_push_pull_args(&argv[1], argc - 1, &lpath, &rpath, &show_progress, &copy_attrs);
if ((lpath != NULL) && (rpath != NULL)) {
return do_sync_push(lpath, rpath, 0 /* no verify APK */, show_progress);
@@ -1409,12 +1418,13 @@ top:
if(!strcmp(argv[0], "pull")) {
int show_progress = 0;
+ int copy_attrs = 0;
const char* rpath = NULL, *lpath = ".";
- parse_push_pull_args(&argv[1], argc - 1, &rpath, &lpath, &show_progress);
+ parse_push_pull_args(&argv[1], argc - 1, &rpath, &lpath, &show_progress, &copy_attrs);
if (rpath != NULL) {
- return do_sync_pull(rpath, lpath, show_progress);
+ return do_sync_pull(rpath, lpath, show_progress, copy_attrs);
}
return usage();