libzed 1.10.2
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#if defined(__linux__)
7#include <dirent.h>
8#elif defined(_WIN32)
9#include <windows.h>
10#else
11#warning 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#if defined(__linux__)
23 DIR *dpdf;
25 dirent *epdf;
27 zpath fileType;
28#elif defined(_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:75
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
~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