Guest User

Untitled

a guest
Jan 14th, 2013
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. // The configuration file name has has the executable name
  2. // but with the ".config" extension.
  3. //
  4. wxFileName configFileName(wxStandardPaths::Get().GetExecutablePath());
  5. configFileName.SetExt("config");
  6.  
  7. // The config object uses the above file name, and captures the defaults.
  8. //
  9. wxFileConfig * pConfig = new wxFileConfig(wxEmptyString,
  10. wxEmptyString,
  11. wxEmptyString,
  12. configFileName.GetFullPath(),
  13. wxCONFIG_USE_GLOBAL_FILE);
  14. pConfig->SetRecordDefaults(); // to capture the defaults
  15. wxFileConfig::Set(pConfig); // to be globally accessible
  16.  
  17. // One of the configuration values is the file name for the exported
  18. // values (the app.exe functionality, unrelated to the config file name).
  19. // It uses a subdirectory with the name built out of the exe path, its name
  20. // without the extension, with the "_OUTPUT" appended.
  21. // For example, "some/path/App.exe" should produce "some/path/App_OUTPUT".
  22. // The file name is again constructed from the bare app name with
  23. // the ".txt" extension.
  24. //
  25. wxFileName outfname(configFileName.GetPath()); // same as the exe path
  26. outfname.AppendDir(configFileName.GetName() + "_OUTPUT"); // the subdir
  27. outfname.SetName(configFileName.GetName()); // same name as app has
  28. outfname.SetExt("txt"); // with the .txt extension
  29. outfname.Normalize(); // actually, my real path contains also ".."
  30.  
  31. // The above constructed filename is the default for the "output" key.
  32. // I expect to be recorded into the pConfig because of the above
  33. // pConfig->SetRecordDefaults(); Is my expectation correct?
  34. //
  35. m_output_filename = pConfig->Read("output", outfname.GetFullPath());
  36.  
  37. if (! configFileName.Exists())
  38. {
  39. pConfig->??? What should be called?
  40. }
  41.  
  42. if ( !IsDirty() || !m_fnLocalFile.GetFullPath() )
  43. return true;
  44.  
  45. wxFileConfig * pConfig = new wxFileConfig(wxEmptyString,
  46. wxEmptyString,
  47. configFileName.GetFullPath(),
  48. wxEmptyString,
  49. wxCONFIG_USE_LOCAL_FILE);
Add Comment
Please, Sign In to add comment