Fix 'adb backup' on Windows
Use the same call sequence that 'adb pull' uses for creating the output file. adb_open_mode() apparently does not work on Windows hosts. Bug 5733007 Change-Id: I48d719c4657c93e19f6790cf1c6da610d49f5806
This commit is contained in:
parent
ce48083fc9
commit
b1dfffe6bb
1 changed files with 24 additions and 2 deletions
|
|
@ -577,9 +577,29 @@ static int logcat(transport_type transport, char* serial, int argc, char **argv)
|
||||||
return 0;
|
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) {
|
static int backup(int argc, char** argv) {
|
||||||
char buf[4096];
|
char buf[4096];
|
||||||
const char* filename = "./backup.ab";
|
char default_name[32];
|
||||||
|
const char* filename = strcpy(default_name, "./backup.ab");
|
||||||
int fd, outFd;
|
int fd, outFd;
|
||||||
int i, j;
|
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 */
|
/* bare "adb backup" or "adb backup -f filename" are not valid invocations */
|
||||||
if (argc < 2) return usage();
|
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) {
|
if (outFd < 0) {
|
||||||
fprintf(stderr, "adb: unable to open file %s\n", filename);
|
fprintf(stderr, "adb: unable to open file %s\n", filename);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue