Browse Subversion Repository
Contents of /trunk/FileIO/src/FileIOConfig.cpp
Parent Directory
| Revision Log
Revision 119 -
( show annotations)
( download)
( as text)
Fri Oct 8 15:41:45 2010 UTC
(13 years, 7 months ago)
by kamoya
File MIME type: text/x-c++src
File size: 1039 byte(s)
avoid ARRAYSIZE macro
| 1 |
#include <array> |
| 2 |
#include <windows.h> |
| 3 |
#include <shlwapi.h> |
| 4 |
#if defined(_MSC_VER) |
| 5 |
#pragma comment(lib, "shlwapi.lib") |
| 6 |
#endif |
| 7 |
|
| 8 |
#include "../../Common/dummy.h" |
| 9 |
|
| 10 |
#include "FileIOConfig.h" |
| 11 |
|
| 12 |
namespace Regnessem |
| 13 |
{ |
| 14 |
namespace AddIn |
| 15 |
{ |
| 16 |
namespace FileIO |
| 17 |
{ |
| 18 |
const LPCTSTR FileIOConfig::SectionName = TEXT("Global"); |
| 19 |
const LPCTSTR FileIOConfig::KeyName = TEXT("FileDir"); |
| 20 |
|
| 21 |
void FileIOConfig::LoadFromFile(const tstring &fileName) |
| 22 |
{ |
| 23 |
if(!PathFileExists(fileName.c_str())) |
| 24 |
return; |
| 25 |
|
| 26 |
std::array<TCHAR, MAX_PATH> buff; |
| 27 |
GetPrivateProfileString(SectionName,KeyName,FileDir.c_str(),buff.data(),std::tuple_size<decltype(buff)>::value,fileName.c_str()); |
| 28 |
FileDir = buff.data(); |
| 29 |
} |
| 30 |
|
| 31 |
void FileIOConfig::SaveToFile(const tstring &fileName) const |
| 32 |
{ |
| 33 |
const tstring dirPath = ExtractFilePath(fileName); |
| 34 |
|
| 35 |
if(!PathFileExists(dirPath.c_str())) |
| 36 |
ForceDirectories(dirPath); |
| 37 |
|
| 38 |
WritePrivateProfileString(SectionName,KeyName,FileDir.c_str(),fileName.c_str()); |
| 39 |
} |
| 40 |
} |
| 41 |
} |
| 42 |
} |
|