Skip to content

Instantly share code, notes, and snippets.

@onlyshk
Created August 8, 2010 05:03
Show Gist options
  • Save onlyshk/513616 to your computer and use it in GitHub Desktop.
Save onlyshk/513616 to your computer and use it in GitHub Desktop.
gboolean image_list_open_dir( ImageList* il, const char* path,
GCancellable* generator_cancellable, GError** error )
{
const char* name = NULL;
const char* file_path = NULL;
struct stat stbuf;
if( il->dir_path && 0 == strcmp( path, il->dir_path ) )
return TRUE;
image_list_close( il );
if( stat( path, &stbuf ) == -1 )
return FALSE;
il->dir_path = g_strdup(path);
il->mtime = stbuf.st_mtime;
GFile* file = g_file_new_for_path (path);
GFileEnumerator* enumerator;
GFileInfo *info;
enumerator = g_file_enumerate_children(file,"standard::name",
0,generator_cancellable, NULL);
info = g_file_enumerator_next_file(enumerator, generator_cancellable, &error);
while ((info = g_file_enumerator_next_file (enumerator, generator_cancellable, &error)) != NULL)
{
GFile* file1 = g_file_get_child (file , g_file_info_get_name (info));
file_path = g_file_get_path (file1);
if( image_list_is_file_supported( file_path ) )
{
il->list = g_list_prepend( il->list, file_path);
}
}
il->list = g_list_reverse( il->list );
il->current = il->list;
g_object_unref (file);
//printf(image_list_get_current_file_path(il));
printf(image_list_get_current(il));
return TRUE;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment