Skip to content

Instantly share code, notes, and snippets.

@onlyshk
Created August 8, 2010 06:12
Show Gist options
  • Save onlyshk/513652 to your computer and use it in GitHub Desktop.
Save onlyshk/513652 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;
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;
GFile* file = g_file_new_for_path (path);
GFileEnumerator* enumerator;
GFileInfo *info;
char* file_path = NULL;
il->dir_path = g_strdup( path );
il->mtime = stbuf.st_mtime;
enumerator = g_file_enumerate_children(file,"standard::name",
0,generator_cancellable, NULL);
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_basename(file1);
if( image_list_is_file_supported( file_path ) )
{
il->list = g_list_prepend( il->list, g_strdup(file_path));
}
g_object_unref(file1);
}
il->list = g_list_reverse( il->list );
il->current = il->list;
g_object_unref (file);
g_object_unref (enumerator);
return TRUE;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment