comparison src/evdev-plug/ed_internals.c @ 438:4fec4a3ca1a4 trunk

[svn] - evdev-plug: check that the player local datadir exists before attempting to create evdev-plug.conf
author giacomo
date Mon, 15 Jan 2007 14:04:11 -0800
parents c18fd1befd1f
children d124034ebea3
comparison
equal deleted inserted replaced
437:e1c6b223431e 438:4fec4a3ca1a4
800 gchar *config_pathfilename = NULL; 800 gchar *config_pathfilename = NULL;
801 gchar *config_datadir = NULL; 801 gchar *config_datadir = NULL;
802 802
803 config_datadir = (gchar*)audacious_get_localdir(); 803 config_datadir = (gchar*)audacious_get_localdir();
804 config_pathfilename = g_build_filename( config_datadir , PLAYER_LOCALRC_FILE , NULL ); 804 config_pathfilename = g_build_filename( config_datadir , PLAYER_LOCALRC_FILE , NULL );
805 g_free( config_datadir );
806 805
807 keyfile = g_key_file_new(); 806 keyfile = g_key_file_new();
808 807
809 g_key_file_set_string( keyfile , "___plugin___" , "config_ver" , ED_VERSION_CONFIG ); 808 g_key_file_set_string( keyfile , "___plugin___" , "config_ver" , ED_VERSION_CONFIG );
810 809
823 ed_config_save_from_list_bindings_foreach , keyfile , info ); 822 ed_config_save_from_list_bindings_foreach , keyfile , info );
824 iter_list = g_list_next( iter_list ); 823 iter_list = g_list_next( iter_list );
825 } 824 }
826 825
827 keyfile_str = g_key_file_to_data( keyfile , &keyfile_str_len , NULL ); 826 keyfile_str = g_key_file_to_data( keyfile , &keyfile_str_len , NULL );
828 iochan = g_io_channel_new_file( config_pathfilename , "w" , NULL ); 827 if ( g_file_test( config_datadir , G_FILE_TEST_IS_DIR ) == TRUE )
829 g_io_channel_set_encoding( iochan , "UTF-8" , NULL ); 828 {
830 g_io_channel_write_chars( iochan , keyfile_str , keyfile_str_len , NULL , NULL ); 829 iochan = g_io_channel_new_file( config_pathfilename , "w" , NULL );
831 g_io_channel_shutdown( iochan , TRUE , NULL ); 830 g_io_channel_set_encoding( iochan , "UTF-8" , NULL );
832 g_io_channel_unref( iochan ); 831 g_io_channel_write_chars( iochan , keyfile_str , keyfile_str_len , NULL , NULL );
832 g_io_channel_shutdown( iochan , TRUE , NULL );
833 g_io_channel_unref( iochan );
834 }
835 else
836 {
837 g_warning( _("event-device-plugin: unable to access local directory %s , settings will not be saved.\n") ,
838 config_datadir );
839 }
833 840
834 g_free( keyfile_str ); 841 g_free( keyfile_str );
842 g_free( config_datadir );
835 g_key_file_free( keyfile ); 843 g_key_file_free( keyfile );
836 return 0; 844 return 0;
837 } 845 }
838 846
839 847