IGFD: fix extension-less overwrite check

This commit is contained in:
tildearrow 2023-09-10 03:38:10 -05:00
parent 52b071aa6b
commit 4baefa569b
2 changed files with 12 additions and 3 deletions

View file

@ -1934,14 +1934,23 @@ namespace IGFD
prCurrentPath = vCurrentPath;
}
bool IGFD::FileManager::IsFileExist(const std::string& vFile)
bool IGFD::FileManager::IsFileExist(const std::string& vFile, const std::string& vFileExt)
{
std::ifstream docFile(vFile, std::ios::in);
logV("IGFD: IsFileExist(%s)",vFile);
if (docFile.is_open())
{
docFile.close();
return true;
}
std::ifstream docFileE(vFile+vFileExt, std::ios::in);
logV("IGFD: IsFileExist(%s)",vFile+vFileExt);
if (docFileE.is_open())
{
docFileE.close();
return true;
}
return false;
}
@ -4564,7 +4573,7 @@ namespace IGFD
{
if (prFileDialogInternal.puIsOk) // catched only one time
{
if (!prFileDialogInternal.puFileManager.IsFileExist(GetFilePathName())) // not existing => quit dialog
if (!prFileDialogInternal.puFileManager.IsFileExist(GetFilePathName(),prFileDialogInternal.puFilterManager.GetSelectedFilter().firstFilter)) // not existing => quit dialog
{
QuitFrame();
return true;

View file

@ -913,7 +913,7 @@ namespace IGFD
bool SetPathOnParentDirectoryIfAny(); // compose paht on parent directory
std::string GetCurrentPath(); // get the current path
void SetCurrentPath(const std::string& vCurrentPath); // set the current path
static bool IsFileExist(const std::string& vFile);
static bool IsFileExist(const std::string& vFile, const std::string& vFileExt);
void SetDefaultFileName(const std::string& vFileName);
bool SelectDirectory(const FileInfos& vInfos); // enter directory
void SelectFileName(const FileDialogInternal& vFileDialogInternal,