Hi all,
Doing something like:
geany /tmp
on the command line geany will open with a empty file named "/tmp"
which cannot be saved because there is a directory /tmp already.
The attached patch just ignores all filenames passed on the
command line which are directories.
Cheers,
Erik
--
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/
=== modified file 'src/main.c'
Index: geany-bzr/src/main.c
===================================================================
--- geany-bzr.orig/src/main.c
+++ geany-bzr/src/main.c
@@ -783,6 +783,14 @@
return FALSE;
}
+static gboolean is_directory (const char * path)
+{
+ struct stat sbuf;
+ if (lstat (path, &sbuf) != 0)
+ return FALSE;
+
+ return S_ISDIR (sbuf.st_mode);
+}
/* open files from command line */
static gboolean open_cl_files(gint argc, gchar **argv)
@@ -794,6 +802,13 @@
for (i = 1; i < argc; i++)
{
gchar *filename = main_get_argv_filename(argv[i]);
+
+ if (is_directory (filename))
+ {
+ g_free(filename);
+ continue;
+ }
+
#ifdef G_OS_WIN32
/* It seems argv elements are encoded in CP1252 on a German Windows */
setptr(filename, g_locale_to_utf8(filename, -1, NULL, NULL, NULL));
_______________________________________________
Geany-devel mailing list
[email protected]
http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel