mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-08-15 09:56:00 -04:00
Add filesystem directory enumeration.
Borrow API from std::filesystem -- Boost and C++17.
This commit is contained in:
parent
8119980370
commit
7492984144
2 changed files with 89 additions and 0 deletions
|
@ -78,3 +78,33 @@ bool File::sync() {
|
|||
const auto result = f_sync(&f);
|
||||
return (result == FR_OK);
|
||||
}
|
||||
|
||||
namespace std {
|
||||
namespace filesystem {
|
||||
|
||||
directory_iterator::directory_iterator(
|
||||
const char* path,
|
||||
const char* wild
|
||||
) {
|
||||
impl = std::make_shared<Impl>();
|
||||
const auto result = f_findfirst(&impl->dir, &impl->filinfo, path, wild);
|
||||
if( result != FR_OK ) {
|
||||
impl.reset();
|
||||
// TODO: Throw exception if/when I enable exceptions...
|
||||
}
|
||||
}
|
||||
|
||||
directory_iterator& directory_iterator::operator++() {
|
||||
const auto result = f_findnext(&impl->dir, &impl->filinfo);
|
||||
if( (result != FR_OK) || (impl->filinfo.fname[0] == 0) ) {
|
||||
impl.reset();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool is_regular_file(const file_status s) {
|
||||
return !(s & AM_DIR);
|
||||
}
|
||||
|
||||
} /* namespace filesystem */
|
||||
} /* namespace std */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue