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;
42 if (p_vfs) p_vfs->
begin();
46 if (p_vfs) p_vfs->
end();
50 LOGI(
"nextStream: %d", offset);
55 LOGI(
"selectStream: %d",
index);
57 file_name = get(
index);
58 if (file_name ==
nullptr)
return nullptr;
59 LOGI(
"Using file %s", file_name);
60 assert(p_vfs !=
nullptr);
61 file = p_vfs->open(file_name);
62 return file ? &file :
nullptr;
67 assert(p_vfs !=
nullptr);
68 file = p_vfs->open(path);
69 file_name = file.name();
70 LOGI(
"-> selectStream: %s", path);
71 return file ? &file :
nullptr;
82 const char *
toStr() {
return file_name; }
88 virtual void setPath(
const char *p) { start_path = p; }
94 for (
auto const &dir_entry : fs::recursive_directory_iterator(start_path)) {
108 const char *file_name;
109 const char *exension =
"";
110 const char *start_path =
"/";
111 const char *file_name_pattern =
"*";
112 fs::directory_entry entry;
113 VFS *p_vfs =
nullptr;
115 const char *get(
int idx) {
117 const char *result =
nullptr;
118 for (
auto const &dir_entry : fs::recursive_directory_iterator(start_path)) {
120 if (count++ == idx) {
122 result = entry.path().c_str();
132 const std::filesystem::path &path = file.path();
134 const char *file_name = path.filename().c_str();
135 if (file.is_directory()) {
136 LOGD(
"-> isValidAudioFile: '%s': %d", file_name,
false);
139 StrView strFileTName(file_name);
141 strFileTName.
matches(file_name_pattern);
142 LOGD(
"-> isValidAudioFile: '%s': %d", file_name, result);