mirror of
https://github.com/NotImplementedLife/FSPDS.git
synced 2025-06-19 17:35:34 -04:00
30 lines
546 B
C++
30 lines
546 B
C++
#include "filesystem.hpp"
|
|
|
|
bool DirStream::open(const char* dir)
|
|
{
|
|
if(root!=nullptr)
|
|
closedir(root);
|
|
return nullptr == (root = opendir(dir));
|
|
}
|
|
|
|
bool DirStream::next(char* dest_name)
|
|
{
|
|
if(root==nullptr) return false;
|
|
struct dirent *entry;
|
|
while((entry=readdir(root))!=NULL)
|
|
{
|
|
if(strcmp(".", entry->d_name)==0 || strcmp("..", entry->d_name)==0)
|
|
continue;
|
|
if(entry->d_type != DT_DIR)
|
|
continue;
|
|
strcpy(dest_name, entry->d_name);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void DirStream::close()
|
|
{
|
|
closedir(root);
|
|
root = nullptr;
|
|
} |