GFileSystemModel: Add a "DirectoriesOnly" mode.

This commit is contained in:
Andreas Kling 2019-03-29 17:14:03 +01:00
parent 4d3c5fd83e
commit 6b72c62c5f
Notes: sideshowbarker 2024-07-19 14:54:09 +09:00
3 changed files with 11 additions and 6 deletions

View file

@ -51,7 +51,6 @@ struct GFileSystemModel::Node {
auto full_path = this->full_path(model);
DIR* dirp = opendir(full_path.characters());
dbgprintf("traverse if needed: %s (%p)\n", full_path.characters(), dirp);
if (!dirp)
return;
@ -64,6 +63,8 @@ struct GFileSystemModel::Node {
perror("lstat");
continue;
}
if (model.m_mode == DirectoriesOnly && !S_ISDIR(st.st_mode))
continue;
auto* child = new Node;
child->name = de->d_name;
child->type = S_ISDIR(st.st_mode) ? Node::Type::Directory : Node::Type::File;
@ -91,8 +92,9 @@ struct GFileSystemModel::Node {
}
};
GFileSystemModel::GFileSystemModel(const String& root_path)
GFileSystemModel::GFileSystemModel(const String& root_path, Mode mode)
: m_root_path(FileSystemPath(root_path).string())
, m_mode(mode)
{
update();
}