+static void parse_command_line_add_dir(const gchar *dir, gchar **path, gchar **file,
+ GList **list)
+{
+ GList *files = NULL;
+ gchar *path_parsed;
+
+ path_parsed = g_strdup(dir);
+ parse_out_relatives(path_parsed);
+
+ if (path_list(path_parsed, &files, NULL))
+ {
+ GList *work;
+
+ files = path_list_filter(files, FALSE);
+ files = path_list_sort(files);
+
+ work = files;
+ while (work)
+ {
+ gchar *p;
+
+ p = work->data;
+ if (!*path) *path = remove_level_from_path(p);
+ if (!*file) *file = g_strdup(p);
+ *list = g_list_prepend(*list, p);
+
+ work = work->next;
+ }
+
+ g_list_free(files);
+ }
+
+ g_free(path_parsed);
+}
+
+static void parse_command_line_process_dir(const gchar *dir, gchar **path, gchar **file,
+ GList **list, gchar **first_dir)
+{
+
+ if (!*list && !*first_dir)
+ {
+ *first_dir = g_strdup(dir);
+ }
+ else
+ {
+ if (*first_dir)
+ {
+ parse_command_line_add_dir(*first_dir, path, file, list);
+ g_free(*first_dir);
+ *first_dir = NULL;
+ }
+ parse_command_line_add_dir(dir, path, file, list);
+ }
+}
+
+static void parse_command_line_process_file(const gchar *file_path, gchar **path, gchar **file,
+ GList **list, GList **collection_list, gchar **first_dir)
+{
+
+ if (*first_dir)
+ {
+ parse_command_line_add_dir(*first_dir, path, file, list);
+ g_free(*first_dir);
+ *first_dir = NULL;
+ }
+ parse_command_line_add_file(file_path, path, file, list, collection_list);
+}
+