glib and relative file names



Hey guys
              I am trying to work out a system to pass files to the
application I am working on, now it can accept absolute paths but it doesn't
seem to like relative paths can someone have a look at my code and see why
the G_FILE_TEST_EXISTS check fails? I have tried making the argument and
converting it to an absolute path by getting the output of g_get_current_dir
() which I understand to return the current working directory, but it only
returns the name of my home directory, which is unusual. Can someone shed
some light on this?

The code I am using is below.

if( argc == 1 ) // If no arguments were passed
gtk_window_set_focus( GTK_WINDOW( window ), New( NULL, Notebook ) );
else // Check to see if any files were specified on the cmd line
{
gint i;
for( i = 1; i < argc; i++ )
{
g_print( "\n%s\n", argv[ i ] );
if( g_file_test( argv[ i ], G_FILE_TEST_EXISTS ) )
{
g_print( "File exists!\n" );
gtk_window_set_focus( GTK_WINDOW( window ), open_with( argv[ i ], Notebook )
);
}
}
if( gtk_notebook_get_n_pages( GTK_NOTEBOOK( Notebook ) ) == 0 )
gtk_window_set_focus( GTK_WINDOW( window ), New( NULL, Notebook ) );
}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]