#include "SharedFilterDlg.h"
#include "TestFilterDlg.h"
#include "FileOrFolderSelect.h"
+#include "UniFile.h"
using std::vector;
}
/**
+ * @brief Select filter by file path in the listview.
+ * @param [in] path file path
+ */
+void FileFiltersDlg::SelectFilterByFilePath(const String& path)
+{
+ for (size_t i = 0; i < m_Filters.size(); ++i)
+ {
+ if (m_Filters[i].fullpath == path)
+ {
+ SelectFilterByIndex(static_cast<int>(i + 1));
+ break;
+ }
+ }
+}
+
+/**
* @brief Called before dialog is shown.
* @return Always TRUE.
*/
// Open-dialog asks about overwriting, so we can overwrite filter file
// user has already allowed it.
- if (!CopyFile(templatePath.c_str(), s.c_str(), FALSE))
+ UniMemFile fileIn;
+ UniStdioFile fileOut;
+ if (!fileIn.OpenReadOnly(templatePath) || !fileOut.OpenCreate(s))
{
String msg = strutils::format_string1(
_( "Cannot copy filter template file to filter folder:\n%1\n\nPlease make sure the folder exists and is writable."),
AfxMessageBox(msg.c_str(), MB_ICONERROR);
return;
}
+ String lines;
+ fileIn.ReadStringAll(lines);
+ strutils::replace(lines, _T("${name}"), file);
+ fileOut.WriteString(lines);
+ fileIn.Close();
+ fileOut.Close();
+
EditFileFilter(s);
FileFilterMgr *pMgr = pGlobalFileFilter->GetManager();
int retval = pMgr->AddFilter(s);
m_Filters = pGlobalFileFilter->GetFileFilters(selected);
UpdateFiltersList();
+ SelectFilterByFilePath(s);
}
}
}
m_Filters = pGlobalFileFilter->GetFileFilters(selected);
UpdateFiltersList();
+ SelectFilterByFilePath(userPath);
}
}
}