aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2012-11-22 23:37:12 +0100
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2012-11-22 23:37:12 +0100
commitd800d1535ea01eccd05bf5c7aea093b9f5038e11 (patch)
tree9fef308afa65ef2dc9b5ca3d6c1dfa093d5fbfb8
parent0890a9609a66c544c8c0b3ccd19247637df1e1b5 (diff)
downloadsciteco-d800d1535ea01eccd05bf5c7aea093b9f5038e11.tar.gz
fix current working directory on Windows
-rw-r--r--main.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/main.cpp b/main.cpp
index 042d811..18018ca 100644
--- a/main.cpp
+++ b/main.cpp
@@ -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);