2#include "AudioTools/CoreAudio/AudioBasic/Str.h"
19 virtual bool begin() {
return true;}
25 VFSFile open(
const char* file, FileMode mode = VFS_FILE_READ) {
27 vfs_file.open(
expand(file), mode);
30 VFSFile open(
const std::string& path, FileMode mode = VFS_FILE_READ) {
31 const char* path_str = path.c_str();
32 const char* path_str_exanded =
expand(path_str);
33 LOGI(
"open: %s", path_str_exanded);
34 return this->open(path_str_exanded, mode);
36 bool exists(
const char* path) {
38 return (stat(
expand(path), &buffer) == 0);
40 bool exists(
const std::string& path) {
return exists(path.c_str()); }
41 bool remove(
const char* path) { return ::remove(
expand(path)) == 0; }
42 bool remove(
const std::string& path) {
return remove(path.c_str()); }
43 bool rename(
const char* pathFrom,
const char* pathTo) {
46 bool rename(
const std::string& pathFrom,
const std::string& pathTo) {
47 return rename(pathFrom.c_str(), pathTo.c_str());
49 bool mkdir(
const char* path) { return ::mkdir(
expand(path), 0777) == 0; }
50 bool mkdir(
const std::string& path) {
return mkdir(path.c_str()); }
51 bool rmdir(
const char* path) { return ::rmdir(
expand(path)) == 0; }
52 bool rmdir(
const std::string& path) {
return rmdir(path.c_str()); }
58 const char* mount_point =
"/";
63 const char*
expand(
const char* file) {
64 assert(mount_point !=
nullptr);
65 assert(file !=
nullptr);
67 if (!
StrView(file).startsWith(
"/") && !
StrView(mount_point).endsWith(
"/")) {