37DIR* opendir(
const char* name)
39 if (!name || !*name)
return nullptr;
50 WIN32_FIND_DATAW
find;
51 if ((hnd = FindFirstFileW(nameW.c_str(), &find)) == INVALID_HANDLE_VALUE) {
57 dir->fd =
reinterpret_cast<INT_PTR
>(hnd);
58 dir->data =
new WIN32_FIND_DATAW;
60 memcpy(dir->data, &find,
sizeof(find));
64dirent* readdir(DIR* dir)
68 entry.d_type = DT_UNKNOWN;
70 auto find =
static_cast<WIN32_FIND_DATAW*
>(dir->data);
72 if (!FindNextFileW(
reinterpret_cast<HANDLE
>(dir->fd), find)) {
78 strncpy(entry.d_name, d_name.c_str(), std::size(entry.d_name));
80 entry.d_off = dir->filepos;
81 entry.d_reclen =
static_cast<unsigned short>(strlen(entry.d_name));
88 auto hnd =
reinterpret_cast<HANDLE
>(dir->fd);
89 delete static_cast<WIN32_FIND_DATAW*
>(dir->data);
91 return FindClose(hnd) ? 0 : -1;
94void rewinddir(DIR* dir)
96 auto hnd =
reinterpret_cast<HANDLE
>(dir->fd);
97 auto find =
static_cast<WIN32_FIND_DATAW*
>(dir->data);
100 hnd = FindFirstFileW(dir->mask.c_str(), find);
101 dir->fd =
reinterpret_cast<INT_PTR
>(hnd);
105void seekdir(DIR* dir, off_t offset)
109 if (FindNextFileW(
reinterpret_cast<HANDLE
>(dir->fd),
110 static_cast<WIN32_FIND_DATAW*
>(dir->data))) {
116off_t telldir(DIR* dir)
Like std::string_view, but with the extra guarantee that it refers to a zero-terminated string.
constexpr bool ends_with(std::string_view sv) const
This file implemented 3 utility functions:
auto find(InputRange &&range, const T &value)
u16bit_iterator utf8to16(octet_iterator start, octet_iterator end, u16bit_iterator result)
octet_iterator utf16to8(u16bit_iterator start, u16bit_iterator end, octet_iterator result)
constexpr void repeat(T n, Op op)
Repeat the given operation 'op' 'n' times.