Move mkdirs to adb_utils.
There were duplicate implementations in commandline.cpp and
file_sync_client.cpp.
Change-Id: Ib448f76c0d7ffdcd577336b1c610a881425bc2db
diff --git a/adb/adb_utils.cpp b/adb/adb_utils.cpp
index 604bd57..4b97a14 100644
--- a/adb/adb_utils.cpp
+++ b/adb/adb_utils.cpp
@@ -63,6 +63,25 @@
return result;
}
+int mkdirs(const char *path)
+{
+ int ret;
+ char *x = (char *)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;
+}
+
void dump_hex(const void* data, size_t byte_count) {
byte_count = std::min(byte_count, size_t(16));