SF.net SVN: geany: [547] trunk
ntrel at users.sourceforge.net
ntrel at xxxxx
Tue Jul 11 13:48:29 UTC 2006
Revision: 547
Author: ntrel
Date: 2006-07-11 06:48:24 -0700 (Tue, 11 Jul 2006)
ViewCVS: http://svn.sourceforge.net/geany/?rev=547&view=rev
Log Message:
-----------
Prefix command-line opened files with the current directory so relative paths will work better
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/main.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2006-07-10 16:46:29 UTC (rev 546)
+++ trunk/ChangeLog 2006-07-11 13:48:24 UTC (rev 547)
@@ -1,3 +1,9 @@
+2006-07-11 Nick Treleaven <nick.treleaven at btinternet.com>
+
+ * src/main.c: Prefix command-line opened files with the current
+ directory so relative paths will work better.
+
+
2006-07-10 Enrico Tröger <enrico.troeger at uvena.de>
* src/sci_cb.c: Autocompletion only works on blank lines.
Modified: trunk/src/main.c
===================================================================
--- trunk/src/main.c 2006-07-10 16:46:29 UTC (rev 546)
+++ trunk/src/main.c 2006-07-11 13:48:24 UTC (rev 547)
@@ -316,6 +316,26 @@
}
+/* get the full file path of a command-line argument
+ * N.B. the result should be freed and may contain '/../' or '/./ ' */
+gchar *get_argv_filename(const gchar *filename)
+{
+ gchar *result;
+
+ if (g_path_is_absolute(filename))
+ result = g_strdup(filename);
+ else
+ {
+ //use current dir
+ gchar *cur_dir = g_get_current_dir();
+ result = g_strjoin(
+ G_DIR_SEPARATOR_S, cur_dir, filename, NULL);
+ g_free(cur_dir);
+ }
+ return result;
+}
+
+
#ifdef HAVE_FIFO
static gboolean read_fifo(GIOChannel *source, GIOCondition condition, gpointer data)
{
@@ -356,15 +376,18 @@
gint i;
GIOChannel *ioc;
- for(i = 1; i < argc; i++)
+ for(i = 1; i < argc && argv[i] != NULL; i++)
{
- if (argv[i] && g_file_test(argv[i], G_FILE_TEST_IS_REGULAR || G_FILE_TEST_IS_SYMLINK))
+ gchar *filename = get_argv_filename(argv[i]);
+
+ if (filename && g_file_test(filename, G_FILE_TEST_IS_REGULAR || G_FILE_TEST_IS_SYMLINK))
{
ioc = g_io_channel_unix_new(open(fifo_name, O_WRONLY));
- g_io_channel_write_chars(ioc, argv[i], -1, NULL, NULL);
+ g_io_channel_write_chars(ioc, filename, -1, NULL, NULL);
g_io_channel_flush(ioc, NULL);
g_io_channel_shutdown(ioc, TRUE, NULL);
}
+ g_free(filename);
}
}
@@ -542,7 +565,9 @@
{
if (opened < GEANY_MAX_OPEN_FILES)
{
- document_open_file(-1, argv[i], 0, FALSE, NULL);
+ gchar *filename = get_argv_filename(argv[i]);
+ document_open_file(-1, filename, 0, FALSE, NULL);
+ g_free(filename);
opened++;
}
else
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Commits
mailing list