upd: fixing little INI file read section problem when path separators are not correct

parent 3cc8e808
......@@ -34,11 +34,13 @@
const unsigned int MAX_VALUE_STRING_LENGTH = 4096;
// Bugfix (fwe): Falls kein Pfad und nur ein Dateinamen angebenen ist, muss .\ vorne angehngt werden
std::string fixpath(const std::string& sPath) {
if (sPath.find_first_of(PATH_SEPARATOR) != -1)
return sPath;
std::string FixPath( const std::string& sPath )
{
std::string sCorrectedPathWithSystemSeparator = correctPath( sPath );
if( sCorrectedPathWithSystemSeparator.find_first_of( PATH_SEPARATOR ) != -1 )
return sCorrectedPathWithSystemSeparator;
else
return std::string(".") + PATH_SEPARATOR + sPath;
return std::string( "." ) + PATH_SEPARATOR + sPath;
}
std::vector<std::string> INIFileGetSections(const std::string& sINIFilename) {
......@@ -51,7 +53,7 @@ std::vector<std::string> INIFileGetSections(const std::string& sINIFilename) {
char buf[SECTION_NAME_BUFFER_SIZE];
std::vector<std::string> vsResult;
if (GetPrivateProfileSectionNamesA(buf, SECTION_NAME_BUFFER_SIZE, fixpath(sINIFilename).c_str()) > 0) {
if (GetPrivateProfileSectionNamesA(buf, SECTION_NAME_BUFFER_SIZE, FixPath(sINIFilename).c_str()) > 0) {
char* p = buf;
unsigned int l;
......@@ -74,7 +76,7 @@ std::vector<std::string> INIFileGetKeys(const std::string& sINIFilename, const s
char buf[SECTION_BUFFER_SIZE];
std::vector<std::string> vsResult;
if (GetPrivateProfileSectionA(sSection.c_str(), buf, SECTION_BUFFER_SIZE, fixpath(sINIFilename).c_str()) > 0) {
if (GetPrivateProfileSectionA(sSection.c_str(), buf, SECTION_BUFFER_SIZE, FixPath(sINIFilename).c_str()) > 0) {
char* p = buf;
unsigned int l;
......@@ -107,7 +109,7 @@ std::string INIFileReadString(const std::string& sINIFilename, const std::string
sDefaultValue.c_str(),
(LPSTR) buf,
(DWORD) MAX_VALUE_STRING_LENGTH,
fixpath(sINIFilename).c_str());
FixPath(sINIFilename).c_str());
return std::string(buf);
}
......@@ -119,7 +121,7 @@ bool INIFileWriteString(const std::string& sINIFilename, const std::string& sSec
return (WritePrivateProfileStringA(sSection.c_str(),
sKey.c_str(),
s.c_str(),
fixpath(sINIFilename).c_str()) == TRUE);
FixPath(sINIFilename).c_str()) == TRUE);
}
#endif // _WIN32
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment