- The separator (slash or back slash), exepostfix and exeprefix are initialized from...
[reactos.git] / reactos / tools / bin2res / bin2res.c
index 25dcc05..4399d52 100644 (file)
 
 #if defined(WIN32)
 #define DIR_SEPARATOR "\\"
+#define C_SEP '\\'
+#define C_BAD_SEP '/'
 #else
 #define DIR_SEPARATOR "/"
+#define C_SEP '/'
+#define C_BAD_SEP '\\'
 #endif
 
 extern int mkstemps(char *template, int suffix_len);
@@ -275,6 +279,22 @@ int process_resources(const char* input_file_name, const char* specific_file_nam
     return c == EOF;
 }
 
+char* fix_path_sep(char* name)
+{
+    char *new_name, *ptr;
+
+    ptr = new_name = strdup(name);
+    while(*ptr)
+    {
+        if (*ptr == C_BAD_SEP)
+        {
+            *ptr = C_SEP;
+        }
+        ptr++;
+    }
+    return new_name;
+}
+
 int main(int argc, char **argv)
 {
     int convert_dir = 0, optc;
@@ -295,14 +315,14 @@ int main(int argc, char **argv)
        case 'i':
        case 'o':
            if (specific_file_name) usage();
-           specific_file_name = optarg;
+           specific_file_name = fix_path_sep(optarg);
            optc = ((optc == 'i') ? 'a' : 'x');
            if (convert_dir && convert_dir != optc) usage();
            convert_dir = optc;
        break;
        case 'b':
            if (relative_path) usage();
-           relative_path = optarg;
+           relative_path = fix_path_sep(optarg);
        break;
        case 'f':
            force_overwrite = 1;
@@ -320,7 +340,7 @@ int main(int argc, char **argv)
     }
 
     if (optind + 1 != argc) usage();
-    input_file_name = argv[optind];
+    input_file_name = fix_path_sep(argv[optind]);
 
     if (!convert_dir) usage();