SDB: fix pull bug in Windows 39/12339/1
authorho.namkoong <ho.namkoong@samsung.com>
Wed, 13 Nov 2013 10:56:50 +0000 (19:56 +0900)
committerho.namkoong <ho.namkoong@samsung.com>
Wed, 13 Nov 2013 10:56:50 +0000 (19:56 +0900)
1. If pull path contains device like c:, d:, e:, so on... it shows error message
2. sdb is killed if destination path is device like c:\, d:\, e:\, and so on...

Change-Id: Id536515960968ddb7ab7314136226b30c8b30196

src/file_sync_client.c
src/utils.c
src/utils_windows.c

index 37a1c59f346c9bac8320c671e475c69303fce1f1..fc317a63908f42c4fe7911fa7c06f28c76a5630c 100644 (file)
@@ -199,8 +199,14 @@ int do_sync_copy(char* srcp, char* dstp, FILE_FUNC* srcF, FILE_FUNC* dstF, int i
         }
     }
 
-    if(src_dir == -1 || dst_dir == -1) {
-        LOG_ERROR("src_dir: %d, dst_dir %d\n", src_dir, dst_dir);
+    if(src_dir == -1) {
+        fprintf(stderr, "source directory %s is not a file or directory\n", src_dir);
+        finalize(src_fd, dst_fd, srcF, dstF);
+        return 1;
+    }
+
+    if(dst_dir == -1) {
+        fprintf(stderr, "source directory %s is not a file or directory\n", src_dir);
         finalize(src_fd, dst_fd, srcF, dstF);
         return 1;
     }
index baa22451547b37cd032da7be6d20b82599a156ff..ec5c3862a4e92a34e0851f26c3cc994fec5fbaa4 100755 (executable)
@@ -25,6 +25,7 @@
 
 #include "fdevent.h"
 #include "sdb_constants.h"
+#include "strutils.h"
 
 #define   TRACE_TAG  TRACE_SDB
 
@@ -42,6 +43,19 @@ int is_directory(char* path) {
     struct stat st;
 
     if(stat(path, &st)) {
+
+#if defined(OS_WINDOWS)
+        // For checking drives like c:, d:
+        if(s_strnlen(path, 3) == 2) {
+            if(*(path+1) == ':') {
+                char drive = *path;
+                if( (drive >= 65 && drive <= 90) || (drive >= 97 && drive <= 122)) {
+                    return 1;
+                }
+            }
+        }
+#endif
+
         fprintf(stderr,"cannot stat '%s': %s\n", path, strerror(errno));
         return -1;
     }
@@ -89,7 +103,7 @@ void append_file(char* result_path, char* dir, char* append_dir) {
 
     int len = strlen(append_dir);
     if(len > 0) {
-        if(append_dir[0] == '/') {
+        if(append_dir[0] == '/' || append_dir[0] == '\\') {
             tmp_append = append_dir + 1;
         }
         else {
@@ -101,7 +115,7 @@ void append_file(char* result_path, char* dir, char* append_dir) {
     }
 
     int dir_len = strlen(dir);
-    if(dir_len > 0 && dir[dir_len -1] != '/') {
+    if(dir_len > 0 && dir[dir_len -1] != '/' && dir[dir_len -1] != '\\') {
         snprintf(result_path, PATH_MAX, "%s/%s",dir, tmp_append);
     }
     else {
index 9fb3b07ad1aadb9b0d584f0343f4714d11338ed1..04c322504a59626ad8d4bff81027043846d4d669 100755 (executable)
@@ -346,7 +346,6 @@ static int check_file_err(HANDLE h) {
        return 1;
     }
 
-       _fh_close(h);
        DWORD err = GetLastError();
 
        if(err == ERROR_PATH_NOT_FOUND) {