diff options
author | Christopher Tate <ctate@google.com> | 2011-12-09 16:56:21 -0800 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2011-12-09 16:56:21 -0800 |
commit | 650307df33fc834c251df71c78b00cc0ae6529b7 (patch) | |
tree | 7041ee777fe9065afcbc01a629d4507bc42e8323 | |
parent | 336658c321a6f15f121514342b0a508d84b4b415 (diff) | |
parent | b1dfffe6bb506313a3bc9146d2f6f8c533213193 (diff) | |
download | system_core-650307df33fc834c251df71c78b00cc0ae6529b7.zip system_core-650307df33fc834c251df71c78b00cc0ae6529b7.tar.gz system_core-650307df33fc834c251df71c78b00cc0ae6529b7.tar.bz2 |
am b1dfffe6: Fix \'adb backup\' on Windows
* commit 'b1dfffe6bb506313a3bc9146d2f6f8c533213193':
Fix 'adb backup' on Windows
-rw-r--r-- | adb/commandline.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/adb/commandline.c b/adb/commandline.c index 4c15232..ffc120f 100644 --- a/adb/commandline.c +++ b/adb/commandline.c @@ -577,9 +577,29 @@ static int logcat(transport_type transport, char* serial, int argc, char **argv) return 0; } +static int mkdirs(char *path) +{ + int ret; + char *x = path + 1; + + for(;;) { + x = adb_dirstart(x); + if(x == 0) return 0; + *x = 0; + ret = adb_mkdir(path, 0775); + *x = OS_PATH_SEPARATOR; + if((ret < 0) && (errno != EEXIST)) { + return ret; + } + x++; + } + return 0; +} + static int backup(int argc, char** argv) { char buf[4096]; - const char* filename = "./backup.ab"; + char default_name[32]; + const char* filename = strcpy(default_name, "./backup.ab"); int fd, outFd; int i, j; @@ -602,7 +622,9 @@ static int backup(int argc, char** argv) { /* bare "adb backup" or "adb backup -f filename" are not valid invocations */ if (argc < 2) return usage(); - outFd = adb_open_mode(filename, O_WRONLY | O_CREAT | O_TRUNC, 0640); + adb_unlink(filename); + mkdirs((char *)filename); + outFd = adb_creat(filename, 0640); if (outFd < 0) { fprintf(stderr, "adb: unable to open file %s\n", filename); return -1; |