sdcard: support vfat sdcard since tizen 3.0 06/151506/1
authorjinh0.choi <jinh0.choi@samsung.com>
Thu, 21 Sep 2017 06:12:52 +0000 (15:12 +0900)
committerjinh0.choi <jinh0.choi@samsung.com>
Thu, 21 Sep 2017 06:12:52 +0000 (15:12 +0900)
Change-Id: I12309b3b85ad71bf2418ac4eb85b6a6092490403
Signed-off-by: jinh0.choi <jinh0.choi@samsung.com>
tizen/src/emul_state.c

index eff41e8..54e076b 100644 (file)
@@ -588,14 +588,57 @@ const char* get_vm_data_path(void)
     return vm_data_path;
 }
 
+static int compare_version(const char* version1, const char* version2)
+{
+    int res = 0;
+    char *ver1 = strdup(version1);
+    char *ver2 = strdup(version2);
+    char *remove1 = ver1;
+    char *remove2 = ver2;
+    char *next1 = ver1;
+    char *next2 = ver2;
+
+    while (*next1 != '\0' && *next2 != '\0') {
+        long num1 = strtol(ver1, &next1, 10);
+        long num2 = strtol(ver2, &next2, 10);
+
+        res = num1 - num2;
+        if (res) {
+            break;
+        }
+
+        if (*next1 == '\0' || *next2 == '\0') {
+            res = *next1 - *next2;
+            break;
+        }
+        ver1 = next1 + 1;
+        ver2 = next2 + 1;
+    }
+
+    free(remove1);
+    free(remove2);
+    return res;
+}
+
 const char *get_sdcard_image_path(void)
 {
+    const gchar *sdcard_rel_path;
     const char *vm_data_path = get_vm_data_path();
+    const char *vm_platform_version = get_platform_version();
+    // Since tizen-3.0, vfat SDCard images are used instead of ext4. (+6 for "tizen-")
+    if (compare_version(vm_platform_version + 6, "3.0") >= 0) {
+#ifndef CONFIG_WIN32
+        sdcard_rel_path = g_strdup_printf("%s/../../sdcard/vfat/", vm_data_path);
+#else
+        sdcard_rel_path = g_strdup_printf("%s\\..\\..\\sdcard\\vfat\\", vm_data_path);
+#endif
+    } else {
 #ifndef CONFIG_WIN32
-    const gchar* sdcard_rel_path = g_strdup_printf("%s/../../sdcard/", vm_data_path);
+        sdcard_rel_path = g_strdup_printf("%s/../../sdcard/", vm_data_path);
 #else
-    const gchar* sdcard_rel_path = g_strdup_printf("%s\\..\\..\\sdcard\\", vm_data_path);
+        sdcard_rel_path = g_strdup_printf("%s\\..\\..\\sdcard\\", vm_data_path);
 #endif
+    }
     char sdcard_abs_path[PATH_MAX + 1];
 
     char *ptr = realpath(sdcard_rel_path, sdcard_abs_path);