diff options
-rw-r--r-- | main.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -72,6 +72,19 @@ get_teco_ini(void) return g_strdup(INI_FILE); } +/* + * Windows sometimes sets the current working directory to very obscure + * paths when opening files in the Explorer, but we have to read the + * teco.ini from the directory where our binary resides. + */ +static inline void +fix_cwd(const gchar *program) +{ + gchar *bin_dir = g_path_get_dirname(program); + g_chdir(bin_dir); + g_free(bin_dir); +} + #else static inline gchar * @@ -87,6 +100,8 @@ get_teco_ini(void) return g_build_filename(home, INI_FILE, NULL); } +static inline void fix_cwd(const gchar *program __attribute__((unused))) {} + #endif /* !G_OS_WIN32 */ static inline void @@ -135,6 +150,8 @@ main(int argc, char **argv) static GotoTable cmdline_goto_table; static QRegisterTable local_qregs; + fix_cwd(argv[0]); + process_options(argc, argv); interface.ssm(SCI_SETCARETSTYLE, CARETSTYLE_BLOCK); |