Clean up adb Win32 symlink #ifdefs.
Change-Id: I83ef30e82d820f91960c29f6b737e6e900caaca6
diff --git a/adb/file_sync_client.c b/adb/file_sync_client.c
index 7fb3e3b..ee09d5d 100644
--- a/adb/file_sync_client.c
+++ b/adb/file_sync_client.c
@@ -309,7 +309,9 @@
return err;
}
-#ifdef HAVE_SYMLINKS
+#if defined(_WIN32)
+extern int write_data_link(int fd, const char *path, syncsendbuf *sbuf) __attribute__((error("no symlinks on Windows")));
+#else
static int write_data_link(int fd, const char *path, syncsendbuf *sbuf)
{
int len, ret;
@@ -364,10 +366,8 @@
free(file_buffer);
} else if (S_ISREG(mode))
write_data_file(fd, lpath, sbuf, show_progress);
-#ifdef HAVE_SYMLINKS
else if (S_ISLNK(mode))
write_data_link(fd, lpath, sbuf);
-#endif
else
goto fail;
diff --git a/adb/file_sync_service.c b/adb/file_sync_service.c
index 7933858..7de82b7 100644
--- a/adb/file_sync_service.c
+++ b/adb/file_sync_service.c
@@ -270,7 +270,9 @@
return -1;
}
-#ifdef HAVE_SYMLINKS
+#if defined(_WIN32)
+extern int handle_send_link(int s, char *path, char *buffer) __attribute__((error("no symlinks on Windows")));
+#else
static int handle_send_link(int s, char *path, char *buffer)
{
syncmsg msg;
@@ -321,25 +323,20 @@
return 0;
}
-#endif /* HAVE_SYMLINKS */
+#endif
static int do_send(int s, char *path, char *buffer)
{
- char *tmp;
unsigned int mode;
- int is_link, ret;
+ bool is_link = false;
bool do_unlink;
- tmp = strrchr(path,',');
+ char* tmp = strrchr(path,',');
if(tmp) {
*tmp = 0;
errno = 0;
mode = strtoul(tmp + 1, NULL, 0);
-#ifndef HAVE_SYMLINKS
- is_link = 0;
-#else
is_link = S_ISLNK((mode_t) mode);
-#endif
mode &= 0777;
}
if(!tmp || errno) {
@@ -355,32 +352,26 @@
}
}
-#ifdef HAVE_SYMLINKS
- if(is_link)
- ret = handle_send_link(s, path, buffer);
- else {
-#else
- {
-#endif
- uid_t uid = -1;
- gid_t gid = -1;
- uint64_t cap = 0;
-
- /* copy user permission bits to "group" and "other" permissions */
- mode |= ((mode >> 3) & 0070);
- mode |= ((mode >> 3) & 0007);
-
- tmp = path;
- if(*tmp == '/') {
- tmp++;
- }
- if (is_on_system(path) || is_on_vendor(path)) {
- fs_config(tmp, 0, &uid, &gid, &mode, &cap);
- }
- ret = handle_send_file(s, path, uid, gid, mode, buffer, do_unlink);
+ if (is_link) {
+ return handle_send_link(s, path, buffer);
}
- return ret;
+ uid_t uid = -1;
+ gid_t gid = -1;
+ uint64_t cap = 0;
+
+ /* copy user permission bits to "group" and "other" permissions */
+ mode |= ((mode >> 3) & 0070);
+ mode |= ((mode >> 3) & 0007);
+
+ tmp = path;
+ if(*tmp == '/') {
+ tmp++;
+ }
+ if (is_on_system(path) || is_on_vendor(path)) {
+ fs_config(tmp, 0, &uid, &gid, &mode, &cap);
+ }
+ return handle_send_file(s, path, uid, gid, mode, buffer, do_unlink);
}
static int do_recv(int s, const char *path, char *buffer)