I'm following the example at "Foundations of GTK+" where it explains how to get a folder's content.
I'm using this code to store each filename inside a vector:
GDir* dir = g_dir_open( "fonts/", 0, NULL );
const gchar* file;
if( !g_file_test( "fonts/", G_FILE_TEST_IS_DIR ) )
g_error( "Error: There is no \"fonts\" directory!" );
while( ( file = g_dir_read_name( dir ) ) )
std::cout << "File:" << file << std::endl;
files.push_back( (char*)file );
g_dir_close( dir );
while cout prints ok each filename, doesn't stores correctly into files vector. It seems like I'm storing the address instead the value of file because if I remove g_dir_close(dir) I get almost valid values.
I say almost 'cause what I'm just getting the last filename found repeated number_of_files_on_folder times.
What I'm doing wrong???[/code]