2#include "AudioTools/CoreAudio/AudioBasic/Str.h"
18 virtual bool begin() {
return true; }
24 VFSFile open(
const char* file, FileMode mode = VFS_FILE_READ) {
26 vfs_file.open(
expand(file), mode);
29 VFSFile open(
const std::string& path, FileMode mode = VFS_FILE_READ) {
30 const char* path_str = path.c_str();
31 const char* path_str_exanded =
expand(path_str);
32 LOGI(
"open: %s", path_str_exanded);
33 return this->open(path_str_exanded, mode);
35 bool exists(
const char* path) {
37 return (stat(
expand(path), &buffer) == 0);
39 bool exists(
const std::string& path) {
return exists(path.c_str()); }
40 bool remove(
const char* path) { return ::remove(
expand(path)) == 0; }
41 bool remove(
const std::string& path) {
return remove(path.c_str()); }
42 bool rename(
const char* pathFrom,
const char* pathTo) {
45 bool rename(
const std::string& pathFrom,
const std::string& pathTo) {
46 return rename(pathFrom.c_str(), pathTo.c_str());
48 bool mkdir(
const char* path) { return ::mkdir(
expand(path), 0777) == 0; }
49 bool mkdir(
const std::string& path) {
return mkdir(path.c_str()); }
50 bool rmdir(
const char* path) { return ::rmdir(
expand(path)) == 0; }
51 bool rmdir(
const std::string& path) {
return rmdir(path.c_str()); }
57 const char* mount_point =
"/";
62 const char*
expand(
const char* file) {
63 assert(mount_point !=
nullptr);
64 assert(file !=
nullptr);
66 if (!
StrView(file).startsWith(
"/") && !
StrView(mount_point).endsWith(
"/")) {