summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Gao <jmgao@google.com>2015-11-03 01:31:52 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2015-11-03 01:31:52 +0000
commite9af735de36eade81adc490635ee0076bdb6c79e (patch)
treec9c9355bebaac7e10623d81bbd6082e58f606807
parentd9ff9873df4ef68c105bc84d8dbe098feaaa6c50 (diff)
parent983c41c35375227fe11de41b83e1861f07647313 (diff)
downloadcore-e9af735de36eade81adc490635ee0076bdb6c79e.tar.gz
core-e9af735de36eade81adc490635ee0076bdb6c79e.tar.bz2
core-e9af735de36eade81adc490635ee0076bdb6c79e.zip
Merge "adb: add SyncConnection::Printf."
-rw-r--r--adb/file_sync_client.cpp34
1 files changed, 20 insertions, 14 deletions
diff --git a/adb/file_sync_client.cpp b/adb/file_sync_client.cpp
index 8c9f7a686..3e3bb5740 100644
--- a/adb/file_sync_client.cpp
+++ b/adb/file_sync_client.cpp
@@ -187,6 +187,16 @@ class SyncConnection {
line_printer_.Print(s, LinePrinter::ELIDE);
}
+ void Printf(const char* fmt, ...) __attribute__((__format__(ADB_FORMAT_ARCHETYPE, 2, 3))) {
+ std::string s;
+ va_list ap;
+ va_start(ap, fmt);
+ android::base::StringAppendV(&s, fmt, ap);
+ va_end(ap);
+
+ Print(s);
+ }
+
void Error(const char* fmt, ...) __attribute__((__format__(ADB_FORMAT_ARCHETYPE, 2, 3))) {
std::string s = "adb: error: ";
@@ -308,7 +318,7 @@ static bool SendLargeFile(SyncConnection& sc, const char* path_and_mode,
bytes_copied += ret;
int percentage = static_cast<int>(bytes_copied * 100 / total_size);
- sc.Print(android::base::StringPrintf("%s: %d%%", rpath, percentage));
+ sc.Printf("%s: %d%%", rpath, percentage);
}
adb_close(lfd);
@@ -431,7 +441,7 @@ static bool sync_recv(SyncConnection& sc, const char* rpath, const char* lpath)
bytes_copied += msg.data.size;
int percentage = static_cast<int>(bytes_copied * 100 / size);
- sc.Print(android::base::StringPrintf("%s: %d%%", rpath, percentage));
+ sc.Printf("%s: %d%%", rpath, percentage);
}
adb_close(lfd);
@@ -609,11 +619,9 @@ static bool copy_local_dir_remote(SyncConnection& sc, const char* lpath, const c
free(ci);
}
- sc.Print(android::base::StringPrintf("%s: %d file%s pushed. %d file%s skipped.%s\n",
- rpath,
- pushed, (pushed == 1) ? "" : "s",
- skipped, (skipped == 1) ? "" : "s",
- sc.TransferRate().c_str()));
+ sc.Printf("%s: %d file%s pushed. %d file%s skipped.%s\n", rpath, pushed,
+ (pushed == 1) ? "" : "s", skipped, (skipped == 1) ? "" : "s",
+ sc.TransferRate().c_str());
return true;
}
@@ -678,7 +686,7 @@ static void sync_ls_build_list_cb(unsigned mode, unsigned size, unsigned time,
ci->next = *filelist;
*filelist = ci;
} else {
- args->sc->Print(android::base::StringPrintf("skipping special file '%s'\n", name));
+ args->sc->Printf("skipping special file '%s'\n", name);
}
}
@@ -744,7 +752,7 @@ static bool copy_remote_dir_local(SyncConnection& sc, const char* rpath, const c
while (ci) {
copyinfo* next = ci->next;
if (ci->flag == 0) {
- sc.Print(android::base::StringPrintf("pull: %s -> %s", ci->src, ci->dst));
+ sc.Printf("pull: %s -> %s", ci->src, ci->dst);
if (!sync_recv(sc, ci->src, ci->dst)) {
return false;
}
@@ -760,11 +768,9 @@ static bool copy_remote_dir_local(SyncConnection& sc, const char* rpath, const c
ci = next;
}
- sc.Print(android::base::StringPrintf("%s: %d file%s pulled. %d file%s skipped.%s\n",
- rpath,
- pulled, (pulled == 1) ? "" : "s",
- skipped, (skipped == 1) ? "" : "s",
- sc.TransferRate().c_str()));
+ sc.Printf("%s: %d file%s pulled. %d file%s skipped.%s\n", rpath, pulled,
+ (pulled == 1) ? "" : "s", skipped, (skipped == 1) ? "" : "s",
+ sc.TransferRate().c_str());
return true;
}