#include <string.h>
static GFile *
-gio_id_to_file (AtomCtx *ctx, AtomID *id)
+gio_req_to_file (AtomCtx *ctx, char *req)
{
gchar *root = atom_config_get_str (ctx, "gio", "root");
- gchar *path = atom_id_string (id);
- gchar *filename = g_build_filename (root, path, NULL);
+ gchar *filename = g_build_filename (root, req, NULL);
GFile *file = g_file_new_for_path (filename);
g_free (root);
g_free (filename);
}
static AtomEntry *
-gio_atom_retrieve_entry (AtomCtx *ctx, AtomID *id)
+gio_atom_retrieve_entry (AtomCtx *ctx, char *req)
{
GFile *file;
AtomEntry *atom;
- file = gio_id_to_file (ctx, id);
+ file = gio_req_to_file (ctx, req);
atom = gio_file_to_atom (ctx, file);
g_object_unref (file);
return atom;
}
static void
-gio_enumerate_entries (AtomCtx *ctx, AtomEntry ***entries, size_t *len)
+gio_enumerate_entries (AtomCtx *ctx, char ***reqs, AtomEntry ***entries,
+ size_t *len)
{
GFile *dir;
GFileEnumerator *enumerator;
gchar *name;
gchar *filename;
GPtrArray *array;
+ GPtrArray *filenames;
root = atom_config_get_str (ctx, "gio", "root");
dir = g_file_new_for_path (root);
error = NULL;
return;
}
array = g_ptr_array_new ();
+ filenames = g_ptr_array_new ();
while ((info = g_file_enumerator_next_file (enumerator, NULL, NULL)) != NULL)
{
name = g_file_info_get_name (info);
filename = g_build_filename (root, name, NULL);
- g_object_unref (info);
file = g_file_new_for_path (filename);
entry = gio_file_to_atom (ctx, file);
if (entry)
{
g_ptr_array_add (array, entry);
+ g_ptr_array_add (filenames, g_strdup (name));
}
else
{
}
g_object_unref (file);
g_free (filename);
+ g_object_unref (info);
}
g_object_unref (enumerator);
g_object_unref (dir);
g_free (root);
+ if (reqs)
+ *reqs = filenames->pdata;
if (entries)
*entries = array->pdata;
if (len)
*len = array->len;
g_ptr_array_free (array, FALSE);
-}
-
-static int
-gio_atom_is_feed (AtomCtx *ctx, AtomID *id)
-{
- return (!strcmp (atom_id_string (id), "/"));
+ g_ptr_array_free (filenames, FALSE);
}
AtomBackend *
backend = atom_backend_new ();
atom_backend_retrieve_entry_set (backend, gio_atom_retrieve_entry);
atom_backend_enumerate_entries_set (backend, gio_enumerate_entries);
- atom_backend_is_feed_set (backend, gio_atom_is_feed);
return backend;
}