]> git.tdb.fi Git - libs/core.git/commitdiff
Invent a value for argv[0] if not present
authorMikko Rasa <tdb@tdb.fi>
Sun, 9 Jun 2019 11:35:27 +0000 (14:35 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sun, 9 Jun 2019 12:09:33 +0000 (15:09 +0300)
Gdbserver seems to pass an empty argv[0], at least on Windows.  That
causes problems with the various get_*_dir functions.

source/core/application.cpp

index 1bae2cd68d06c1028c08e8690dbe585c79b6eb9c..aedaa4b6f25c027429f8bff1a5c069078206e7df 100644 (file)
@@ -90,6 +90,15 @@ void Application::set_startup_info(const char *argv0, void *data)
 
        static FS::Path exe;
 
+       if(!argv0 || !*argv0)
+       {
+#ifdef _WIN32
+               argv0 = "application.exe";
+#else
+               argv0 = "./application";
+#endif
+       }
+
        bool has_slash = strchr(argv0, FS::DIRSEP);
        if(!has_slash)
                exe = FS::path_lookup(argv0);