#include "net/disk_cache/simple/simple_file_enumerator.h"
#include "base/files/file.h"
#include "base/files/file_util.h"
#include "base/logging.h"
namespace disk_cache {
#if BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA)
SimpleFileEnumerator::SimpleFileEnumerator(const base::FilePath& path)
: … { … }
SimpleFileEnumerator::~SimpleFileEnumerator() = default;
bool SimpleFileEnumerator::HasError() const { … }
std::optional<SimpleFileEnumerator::Entry> SimpleFileEnumerator::Next() { … }
#else
SimpleFileEnumerator::SimpleFileEnumerator(const base::FilePath& path)
: enumerator_(path,
false,
base::FileEnumerator::FILES) {}
SimpleFileEnumerator::~SimpleFileEnumerator() = default;
bool SimpleFileEnumerator::HasError() const {
return enumerator_.GetError() != base::File::FILE_OK;
}
std::optional<SimpleFileEnumerator::Entry> SimpleFileEnumerator::Next() {
base::FilePath path = enumerator_.Next();
if (path.empty()) {
return std::nullopt;
}
base::FileEnumerator::FileInfo info = enumerator_.GetInfo();
return std::make_optional<Entry>(std::move(path), info.GetSize(),
base::Time(),
info.GetLastModifiedTime());
}
#endif
}