issue 3598 and 2289 - util functions to determine file types by ending

This commit is contained in:
FelixJongleur42
2017-01-19 22:22:49 +01:00
committed by Flössie
parent c94e017d90
commit 62451f471f
7 changed files with 66 additions and 43 deletions

View File

@@ -277,13 +277,14 @@ const ProfileStoreEntry* ProfileStore::findEntryFromFullPathU(Glib::ustring path
if (path == DEFPROFILE_INTERNAL) {
return internalDefaultEntry;
}
// consistently apply casefold() to make sure dot position is correct
const Glib::ustring::size_type lastdot = path.casefold().find_last_of ('.');
size_t lastdot = path.find_last_of ('.');
if (lastdot != Glib::ustring::npos && lastdot <= path.size() - 4 && !path.casefold().compare (lastdot, 4, paramFileExtension))
if ((lastdot != Glib::ustring::npos) && (lastdot <= path.casefold().size() - 4) && (!path.casefold().compare (lastdot, 4, paramFileExtension)))
// removing the extension
{
path = path.substr(0, lastdot);
// now use dot position without casefold()
path = path.substr(0, path.find_last_of ('.'));
}
// dir separator may come from options file and may be \ or /, we convert them to G_DIR_SEPARATOR_S