diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2012-11-22 23:37:12 +0100 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2012-11-22 23:37:12 +0100 |
commit | d800d1535ea01eccd05bf5c7aea093b9f5038e11 (patch) | |
tree | 9fef308afa65ef2dc9b5ca3d6c1dfa093d5fbfb8 /main.cpp | |
parent | 0890a9609a66c544c8c0b3ccd19247637df1e1b5 (diff) | |
download | sciteco-d800d1535ea01eccd05bf5c7aea093b9f5038e11.tar.gz |
fix current working directory on Windows
Diffstat (limited to 'main.cpp')
-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); |