5#include "AudioLogger.h"
6#include "AudioTools/CoreAudio/AudioBasic/StrView.h"
7#include "AudioTools/Disk/AudioSource.h"
8#include "AudioTools/Disk/VFS.h"
9#include "AudioTools/Disk/VFSFile.h"
13namespace fs = std::filesystem;
26 const char *ext =
"") {
27 start_path = startFilePath;
34 const char *ext =
"") {
35 start_path = startFilePath;
47 return (p_vfs) ? p_vfs->
begin() :
false;
52 if (p_vfs) p_vfs->
end();
56 LOGI(
"nextStream: %d", offset);
61 LOGI(
"selectStream: %d",
index);
63 file_name = get(
index);
64 if (file_name ==
nullptr)
return nullptr;
65 LOGI(
"Using file %s", file_name);
66 assert(p_vfs !=
nullptr);
67 file = p_vfs->open(file_name);
68 return file ? &file :
nullptr;
73 if (path ==
nullptr) {
74 LOGE(
"Filename is null")
77 assert(p_vfs !=
nullptr);
78 file = p_vfs->open(path);
79 file_name = file.name();
80 LOGI(
"-> selectStream: %s", path);
81 return file ? &file :
nullptr;
92 const char *
toStr() {
return file_name; }
98 virtual void setPath(
const char *p) { start_path = p; }
104 for (
auto const &dir_entry : fs::recursive_directory_iterator(start_path)) {
118 const char *file_name;
119 const char *exension =
"";
120 const char *start_path =
"/";
121 const char *file_name_pattern =
"*";
122 fs::directory_entry entry;
123 VFS *p_vfs =
nullptr;
125 const char *get(
int idx) {
127 const char *result =
nullptr;
128 for (
auto const &dir_entry : fs::recursive_directory_iterator(start_path)) {
130 if (count++ == idx) {
132 result = entry.path().c_str();
142 const std::filesystem::path &path = file.path();
144 const char *file_name = path.filename().c_str();
145 if (file.is_directory()) {
146 LOGD(
"-> isValidAudioFile: '%s': %d", file_name,
false);
149 StrView strFileTName(file_name);
151 strFileTName.
matches(file_name_pattern);
152 LOGD(
"-> isValidAudioFile: '%s': %d", file_name, result);