More adb cleanup.
This removes adb_dirstart and adb_dirstop. It also fixes a couple of memory
leaks by switching to std::string. This also fixes the bug in the previous
change --- mkdirs is given input like "/system/bin/sh" and only expected to
create "/system/bin". In a later change, we should remove mkdirs and only
expose the intended "unlink && mkdirs && create" functionality.
Change-Id: I30289dc1b3dff575cc1b158d993652178f587552
diff --git a/adb/sysdeps.h b/adb/sysdeps.h
index 3a3ffda..c033999 100644
--- a/adb/sysdeps.h
+++ b/adb/sysdeps.h
@@ -58,6 +58,7 @@
#include "fdevent.h"
+#define OS_PATH_SEPARATORS "\\/"
#define OS_PATH_SEPARATOR '\\'
#define OS_PATH_SEPARATOR_STR "\\"
#define ENV_PATH_SEPARATOR_STR ";"
@@ -122,9 +123,8 @@
#undef unlink
#define unlink ___xxx_unlink
-static __inline__ int adb_mkdir(const std::string& path, int mode)
-{
- return _mkdir(path);
+static __inline__ int adb_mkdir(const std::string& path, int mode) {
+ return _mkdir(path.c_str());
}
#undef mkdir
#define mkdir ___xxx_mkdir
@@ -236,32 +236,7 @@
extern int adb_socketpair( int sv[2] );
-static __inline__ size_t adb_dirstart(const std::string& path, size_t pos = 0) {
- size_t p = path.find('/', pos);
- size_t p2 = path.find('\\', pos);
-
- if ( p == std::string::npos )
- p = p2;
- else if ( p2 != std::string::npos && p2 > p )
- p = p2;
-
- return p;
-}
-
-static __inline__ size_t adb_dirstop(const std::string& path) {
- size_t p = path.rfind('/');
- size_t p2 = path.rfind('\\');
-
- if ( p == std::string::npos )
- p = p2;
- else if ( p2 != std::string::npos && p2 > p )
- p = p2;
-
- return p;
-}
-
-static __inline__ int adb_is_absolute_host_path( const char* path )
-{
+static __inline__ int adb_is_absolute_host_path(const char* path) {
return isalpha(path[0]) && path[1] == ':' && path[2] == '\\';
}
@@ -286,6 +261,7 @@
#include <string>
+#define OS_PATH_SEPARATORS "/"
#define OS_PATH_SEPARATOR '/'
#define OS_PATH_SEPARATOR_STR "/"
#define ENV_PATH_SEPARATOR_STR ":"
@@ -524,14 +500,6 @@
{
}
-static __inline__ size_t adb_dirstart(const std::string& path, size_t pos = 0) {
- return path.find('/', pos);
-}
-
-static __inline__ size_t adb_dirstop(const std::string& path) {
- return path.rfind('/');
-}
-
static __inline__ int adb_is_absolute_host_path(const char* path) {
return path[0] == '/';
}