MCPcopy Create free account
hub / github.com/WinMerge/winmerge / LoadFromDirectory

Method LoadFromDirectory

Src/FileFilterMgr.cpp:52–82  ·  view source on GitHub ↗

* @brief Load all filter files matching pattern from disk into internal filter set. * @param [in] dir Directory from where filters are loaded. * @param [in] szPattern Pattern for filters to load filters, for example "*.flt". * @param [in] szExt File-extension of filter files. */

Source from the content-addressed store, hash-verified

50 * @param [in] szExt File-extension of filter files.
51 */
52void FileFilterMgr::LoadFromDirectory(const String& dir, const String& szPattern, const String& szExt)
53{
54 try
55 {
56 DirItemArray dirs, files;
57 DirTravel::LoadAndSortFiles(dir, &dirs, &files, false);
58 Glob glb(ucr::toUTF8(szPattern));
59
60 for (DirItem& item: files)
61 {
62 String filename = item.filename;
63 if (!glb.match(ucr::toUTF8(filename)))
64 continue;
65 if (!szExt.empty())
66 {
67 // caller specified a specific extension
68 // (This is really a workaround for brokenness in windows, which
69 // doesn't screen correctly on extension in pattern)
70 const String ext = filename.substr(filename.length() - szExt.length());
71 if (strutils::compare_nocase(szExt, ext) != 0)
72 return;
73 }
74
75 String filterpath = paths::ConcatPath(dir, filename);
76 AddFilter(filterpath);
77 }
78 }
79 catch (...)
80 {
81 }
82}
83
84/**
85 * @brief Removes filter from filterlist.

Callers 1

Calls 7

LoadAndSortFilesFunction · 0.85
ConcatPathFunction · 0.85
toUTF8Function · 0.50
compare_nocaseFunction · 0.50
matchMethod · 0.45
emptyMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected