Changeset 178


Ignore:
Timestamp:
10/08/2008 04:59:01 PM (4 years ago)
Author:
guyru
Message:

use more standard path for saving configuration file under Windows

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/MainFrame.cpp

    r177 r178  
    4141#include <wx/version.h> 
    4242#include <wx/filename.h> 
     43#include <wx/stdpaths.h> 
    4344 
    4445 //include the images for the dice        
     
    7677        SetIcon(wxIcon(icon32_xpm)); 
    7778 
    78         /* Check if there is configuration file under old-name and 
    79          * rename it 
    80          */ 
    81         wxString home_path = wxFileName::GetHomeDir(); 
    82         if (wxFileExists(home_path+wxT("/.OpenYahtzee"))) { 
    83                 // we don't won't to overwrite newer files. 
    84                 wxRenameFile(home_path+wxT("/.OpenYahtzee"),home_path+wxT("/.openyahtzee"),false); 
    85         } 
    86  
    87          
    88         std::string config_file; 
    89         config_file = (home_path.utf8_str()); 
    9079        #ifndef PORTABLE 
    91                 config_file += "/.openyahtzee.new"; 
     80                wxString config_file = wxStandardPaths::Get().GetUserConfigDir() + wxT("/.openyahtzee"); 
     81                wxString old_config_file = wxFileName::GetHomeDir() + wxT("/.OpenYahtzee"); 
     82                //rename old configuration file 
     83                if (wxFileExists(old_config_file)) { 
     84                        wxRenameFile(old_config_file,config_file,false); 
     85                } 
    9286        #else 
    93                 config_file += "/openyahtzee.dat"; 
     87                wxString config_file = wxStandardPaths::Get().GetExecutablePath() + wxT("/openyahtzee.dat"); 
    9488        #endif 
    9589 
    96         m_config = new configuration::Configuration(config_file); 
     90         
     91        std::string config_file_str; 
     92        config_file_str = config_file.utf8_str(); 
     93        m_config = new configuration::Configuration(config_file_str); 
    9794 
    9895        m_evt_handler = new MainFrameEvtHandler(this); 
Note: See TracChangeset for help on using the changeset viewer.