libzed 1.9.9
A general-purpose library for quick and simple data manipulation.
 
Loading...
Searching...
No Matches
list.hpp
1#pragma once
2
3#include "../core/generator.hpp"
4#include "../core/string.hpp"
5
6#ifdef __linux__
7#include <dirent.h>
8#elif _WIN32
9#include <windows.h>
10#else
11#error file::list is incompatible with this OS! Please create a pull request or open an issue on GitHub.
12#endif
13
14namespace z {
15namespace file {
16
20struct dirscan {
21#ifdef __linux__
23 DIR *dpdf;
25 dirent *epdf;
28#elif _WIN32
30 WIN32_FIND_DATA fd;
32 HANDLE hFind;
33#endif
35 bool showAll;
37 bool used;
38
41};
42
64core::generator<zpath, dirscan> listFiles(const zpath &dir, const zpath &fileType = "*", bool showAll = true) noexcept;
65
83core::generator<zpath, dirscan> listDirs(const zpath &dir, bool showAll = false) noexcept;
84} // namespace file
85} // namespace z
A wrapper for std::vector.
Definition array.hpp:72
zpath dir() noexcept
Get the current working directory.
core::generator< zpath, dirscan > listDirs(const zpath &dir, bool showAll=false) noexcept
List all sub-directories in the given directory.
core::generator< zpath, dirscan > listFiles(const zpath &dir, const zpath &fileType="*", bool showAll=true) noexcept
List all files of a given type in the given directory.
State management struct for directory scanning generators.
Definition list.hpp:20
WIN32_FIND_DATA fd
Directory handle.
Definition list.hpp:30
DIR * dpdf
Directory handle.
Definition list.hpp:23
dirent * epdf
File handle.
Definition list.hpp:25
zpath fileType
The file type to filter by.
Definition list.hpp:27
HANDLE hFind
File handle.
Definition list.hpp:32
~dirscan()
Destructor.
bool used
Whether the directory has been opened yet.
Definition list.hpp:37
bool showAll
Whether to include hidden files in the output.
Definition list.hpp:35