]> git.rm.cloudns.org Git - xonotic/netradiant.git/commitdiff
radiant: fix command-line opening on windows
authorThomas Debesse <dev@illwieckz.net>
Sun, 14 Jul 2019 04:06:08 +0000 (06:06 +0200)
committerThomas Debesse <dev@illwieckz.net>
Mon, 22 Jul 2019 02:09:24 +0000 (04:09 +0200)
clean-up windows path, especially use '/' instead of '\'
as directory separator since since radiant is hardcoded
to use an lookup for '/' anywhere.

radiant/main.cpp

index 386f7106c2dacbd8e5e5b7e88b1481052b3aa7c7..ff52a200dd867224991a45803dd3d7d5849b5e13 100644 (file)
@@ -521,29 +521,39 @@ int main( int argc, char* argv[] ){
 #endif
 
        const char* mapname = NULL;
+
+#if GDEF_OS_WINDOWS
+       StringOutputStream mapname_buffer( 256 );
+#endif
+
     char const *error = NULL;
+
        if ( !ui::init( &argc, &argv, "<filename.map>", &error) ) {
                g_print( "%s\n", error );
                return -1;
        }
 
        // Gtk already removed parsed `--options`
-       if (argc == 2) {
-               if ( strlen( argv[1] ) > 1 ) {
-                       if ( g_str_has_suffix( argv[1], ".map" ) ) {
-                               if ( g_path_is_absolute( argv[1] ) ) {
-                                       mapname = argv[1];
-                               }
-                               else {
-                                       mapname = g_build_filename( g_get_current_dir(), argv[1], NULL );
+       if ( argc == 2 ) {
+               if ( strlen( argv[ 1 ] ) > 1 ) {
+                       if ( g_str_has_suffix( argv[ 1 ], ".map" ) ) {
+                               mapname = argv[ 1 ];
+
+                               if ( !g_path_is_absolute( mapname ) ) {
+                                       mapname = g_build_filename( g_get_current_dir(), mapname, NULL );
                                }
+
+#if GDEF_OS_WINDOWS
+                               mapname_buffer << PathCleaned( mapname );
+                               mapname = mapname_buffer.c_str();
+#endif
                        }
                        else {
-                               g_print( "bad file name, will not load: %s\n", argv[1] );
+                               g_print( "bad file name, will not load: %s\n", mapname );
                        }
                }
        }
-       else if (argc > 2) {
+       else if ( argc > 2 ) {
                g_print ( "%s\n", "too many arguments" );
                return -1;
        }