You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
831 B
46 lines
831 B
/*
|
|
* Copyright 2023 ailurux <ailuruxx@gmail.com>
|
|
*
|
|
* SPDX-License-Identifier: GPL-3.0-only
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <string>
|
|
#include <optional>
|
|
|
|
#include "ff.h"
|
|
|
|
namespace lua {
|
|
|
|
// Note for when reading FILINFO, that we are in LFN mode:
|
|
// http://elm-chan.org/fsw/ff/doc/sfileinfo.html
|
|
struct FileEntry {
|
|
int index;
|
|
bool isHidden;
|
|
bool isDirectory;
|
|
std::string filepath;
|
|
std::string name;
|
|
};
|
|
|
|
class FileIterator {
|
|
public:
|
|
FileIterator(std::string filepath, bool showHidden);
|
|
~FileIterator();
|
|
|
|
auto value() const -> const std::optional<FileEntry>&;
|
|
auto next() -> void;
|
|
auto prev() -> void;
|
|
|
|
private:
|
|
FF_DIR dir_;
|
|
std::string original_path_;
|
|
bool show_hidden_;
|
|
|
|
std::optional<FileEntry> current_;
|
|
int offset_;
|
|
|
|
auto iterate(bool reverse = false) -> bool;
|
|
};
|
|
|
|
} // namespace lua
|
|
|