Skip to content

Commit 04890cc

Browse files
committed
[ADD] : add an option for not show hidden files (file strating with a .) with the flag ImGuiFileDialogFlags_DontShowHiddenFiles
1 parent 57c25e8 commit 04890cc

2 files changed

Lines changed: 32 additions & 31 deletions

File tree

ImGuiFileDialog.cpp

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2154,45 +2154,45 @@ namespace IGFD
21542154
infos.fileName = ent->d_name;
21552155
infos.fileName_optimized = OptimizeFilenameForSearchOperations(infos.fileName);
21562156

2157-
if (infos.fileName != "."
2158-
|| dlg_filters.empty()) // in directory mode we must display the curent dir "."
2157+
if (infos.fileName.empty() || infos.fileName == ".") continue; // filename empty or filename is the current dir '.'
2158+
if (infos.fileName != ".." && (dlg_flags & ImGuiFileDialogFlags_DontShowHiddenFiles) && infos.fileName[0] == '.') continue; // dont show hidden files
2159+
if (dlg_filters.empty()) continue; // in directory mode we must display the curent dir ".")
2160+
2161+
switch (ent->d_type)
2162+
{
2163+
case DT_REG:
2164+
infos.type = 'f'; break;
2165+
case DT_DIR:
2166+
infos.type = 'd'; break;
2167+
case DT_LNK:
2168+
infos.type = 'l'; break;
2169+
}
2170+
2171+
if (infos.type == 'f' ||
2172+
infos.type == 'l') // link can have the same extention of a file
21592173
{
2160-
switch (ent->d_type)
2174+
size_t lpt = infos.fileName.find_last_of('.');
2175+
if (lpt != std::string::npos)
21612176
{
2162-
case DT_REG:
2163-
infos.type = 'f'; break;
2164-
case DT_DIR:
2165-
infos.type = 'd'; break;
2166-
case DT_LNK:
2167-
infos.type = 'l'; break;
2177+
infos.ext = infos.fileName.substr(lpt);
21682178
}
21692179

2170-
if (infos.type == 'f' ||
2171-
infos.type == 'l') // link can have the same extention of a file
2180+
if (!dlg_filters.empty())
21722181
{
2173-
size_t lpt = infos.fileName.find_last_of('.');
2174-
if (lpt != std::string::npos)
2175-
{
2176-
infos.ext = infos.fileName.substr(lpt);
2177-
}
2178-
2179-
if (!dlg_filters.empty())
2182+
// check if current file extention is covered by current filter
2183+
// we do that here, for avoid doing that during filelist display
2184+
// for better fps
2185+
if (!m_SelectedFilter.empty() && // selected filter exist
2186+
(!m_SelectedFilter.filterExist(infos.ext) && // filter not found
2187+
m_SelectedFilter.filter != ".*"))
21802188
{
2181-
// check if current file extention is covered by current filter
2182-
// we do that here, for avoid doing that during filelist display
2183-
// for better fps
2184-
if (!m_SelectedFilter.empty() && // selected filter exist
2185-
(!m_SelectedFilter.filterExist(infos.ext) && // filter not found
2186-
m_SelectedFilter.filter != ".*"))
2187-
{
2188-
continue;
2189-
}
2189+
continue;
21902190
}
21912191
}
2192-
2193-
CompleteFileInfos(&infos);
2194-
m_FileList.push_back(infos);
21952192
}
2193+
2194+
CompleteFileInfos(&infos);
2195+
m_FileList.push_back(infos);
21962196
}
21972197

21982198
for (i = 0; i < n; i++)

ImGuiFileDialog.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,8 @@ typedef int ImGuiFileDialogFlags; // -> enum ImGuiFileDialogFlags_
484484
enum ImGuiFileDialogFlags_
485485
{
486486
ImGuiFileDialogFlags_None = 0,
487-
ImGuiFileDialogFlags_ConfirmOverwrite = 1 << 0,
487+
ImGuiFileDialogFlags_ConfirmOverwrite = 1 << 0, // show confirm to overwrite dialog
488+
ImGuiFileDialogFlags_DontShowHiddenFiles = 1 << 1 // dont show hidden file (file starting with a .)
488489
};
489490

490491
#ifdef __cplusplus

0 commit comments

Comments
 (0)