SF.net SVN: geany: [1520] trunk
ntrel at users.sourceforge.net
ntrel at xxxxx
Fri May 11 11:42:01 UTC 2007
Revision: 1520
http://svn.sourceforge.net/geany/?rev=1520&view=rev
Author: ntrel
Date: 2007-05-11 04:42:00 -0700 (Fri, 11 May 2007)
Log Message:
-----------
Move search_get_file_list() to utils.c.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/search.c
trunk/src/utils.c
trunk/src/utils.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2007-05-10 16:36:50 UTC (rev 1519)
+++ trunk/ChangeLog 2007-05-11 11:42:00 UTC (rev 1520)
@@ -1,3 +1,9 @@
+2007-05-11 Nick Treleaven <nick.treleaven at btinternet.com>
+
+ * src/utils.c, src/utils.h, src/search.c:
+ Move search_get_file_list() to utils.c.
+
+
2007-05-10 Nick Treleaven <nick.treleaven at btinternet.com>
* data/global.tags:
Modified: trunk/src/search.c
===================================================================
--- trunk/src/search.c 2007-05-10 16:36:50 UTC (rev 1519)
+++ trunk/src/search.c 2007-05-11 11:42:00 UTC (rev 1520)
@@ -81,9 +81,7 @@
static gchar **search_get_argv(const gchar **argv_prefix, const gchar *dir);
-static GSList *search_get_file_list(const gchar *path, guint *length);
-
static void
on_find_replace_checkbutton_toggled(GtkToggleButton *togglebutton, gpointer user_data);
@@ -1206,11 +1204,18 @@
guint prefix_len, list_len, i, j;
gchar **argv;
GSList *list, *item;
+ GError *error = NULL;
g_return_val_if_fail(dir != NULL, NULL);
prefix_len = g_strv_length((gchar**)argv_prefix);
- list = search_get_file_list(dir, &list_len);
+ list = utils_get_file_list(dir, &list_len, &error);
+ if (error)
+ {
+ msgwin_status_add(_("Could not open directory (%s)"), error->message);
+ g_error_free(error);
+ return NULL;
+ }
if (list == NULL) return NULL;
argv = g_new(gchar*, prefix_len + list_len + 1);
@@ -1231,43 +1236,6 @@
}
-/* Gets a sorted list of files in the current directory.
- * The list and the data in the list should be freed after use.
- * Returns: The list or NULL if no files found.
- * *length is set to the number of non-NULL data items in the list. */
-static GSList *search_get_file_list(const gchar *path, guint *length)
-{
- GError *error = NULL;
- GSList *list = NULL;
- guint len = 0;
- GDir *dir;
-
- g_return_val_if_fail(path != NULL, NULL);
-
- dir = g_dir_open(path, 0, &error);
- if (error)
- {
- msgwin_status_add(_("Could not open directory (%s)"), error->message);
- g_error_free(error);
- *length = 0;
- return NULL;
- }
-
- while (1)
- {
- const gchar *filename = g_dir_read_name(dir);
- if (filename == NULL) break;
-
- list = g_slist_insert_sorted(list, g_strdup(filename), (GCompareFunc) strcmp);
- len++;
- }
- g_dir_close(dir);
-
- *length = len;
- return list;
-}
-
-
static gboolean search_read_io (GIOChannel *source,
GIOCondition condition,
gpointer data)
Modified: trunk/src/utils.c
===================================================================
--- trunk/src/utils.c 2007-05-10 16:36:50 UTC (rev 1519)
+++ trunk/src/utils.c 2007-05-11 11:42:00 UTC (rev 1520)
@@ -1642,3 +1642,40 @@
}
+/* Gets a sorted list of files in the specified directory.
+ * The list and the data in the list should be freed after use.
+ * Returns: The list or NULL if no files found.
+ * length will point to the number of non-NULL data items in the list, unless NULL.
+ * error is the location for storing a possible error, or NULL. */
+GSList *utils_get_file_list(const gchar *path, guint *length, GError **error)
+{
+ GSList *list = NULL;
+ guint len = 0;
+ GDir *dir;
+
+ if (error)
+ *error = NULL;
+ if (length)
+ *length = 0;
+ g_return_val_if_fail(path != NULL, NULL);
+
+ dir = g_dir_open(path, 0, error);
+ if (NZV(error))
+ return NULL;
+
+ while (1)
+ {
+ const gchar *filename = g_dir_read_name(dir);
+ if (filename == NULL) break;
+
+ list = g_slist_insert_sorted(list, g_strdup(filename), (GCompareFunc) strcmp);
+ len++;
+ }
+ g_dir_close(dir);
+
+ if (length)
+ *length = len;
+ return list;
+}
+
+
Modified: trunk/src/utils.h
===================================================================
--- trunk/src/utils.h 2007-05-10 16:36:50 UTC (rev 1519)
+++ trunk/src/utils.h 2007-05-11 11:42:00 UTC (rev 1520)
@@ -171,6 +171,10 @@
* If first is NULL, NULL is returned. */
gchar **utils_strv_new(gchar *first, ...) G_GNUC_NULL_TERMINATED;
+
gint utils_mkdir(const gchar *path, gboolean create_parent_dirs);
+/* Gets a sorted list of files in the specified directory. */
+GSList *utils_get_file_list(const gchar *path, guint *length, GError **error);
+
#endif
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