2023-11-19 08:22:46 +00:00
|
|
|
#pragma once
|
|
|
|
#include <mutex>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "common/fs_file.h"
|
2024-01-26 16:01:27 +00:00
|
|
|
#include <common/io_file.h>
|
2023-11-19 08:22:46 +00:00
|
|
|
|
|
|
|
namespace Core::FileSys {
|
|
|
|
|
|
|
|
class MntPoints {
|
|
|
|
public:
|
|
|
|
struct MntPair {
|
|
|
|
std::string host_path;
|
|
|
|
std::string guest_path; // e.g /app0/
|
|
|
|
};
|
|
|
|
|
|
|
|
MntPoints() = default;
|
|
|
|
virtual ~MntPoints() = default;
|
|
|
|
void mount(const std::string& host_folder, const std::string& guest_folder);
|
|
|
|
void unmount(const std::string& path);
|
|
|
|
void unmountAll();
|
|
|
|
std::string getHostDirectory(const std::string& guest_directory);
|
2023-11-19 08:48:59 +00:00
|
|
|
std::string getHostFile(const std::string& guest_file);
|
2023-11-19 08:22:46 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
std::vector<MntPair> m_mnt_pairs;
|
|
|
|
std::mutex m_mutex;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct File {
|
|
|
|
std::atomic_bool isOpened;
|
|
|
|
std::atomic_bool isDirectory;
|
|
|
|
std::string m_host_name;
|
|
|
|
std::string m_guest_name;
|
2024-01-26 16:01:27 +00:00
|
|
|
IOFile f;
|
2023-11-19 08:22:46 +00:00
|
|
|
//std::vector<Common::FS::DirEntry> dirents;
|
|
|
|
u32 dirents_index;
|
|
|
|
std::mutex m_mutex;
|
|
|
|
};
|
|
|
|
class HandleTable {
|
|
|
|
public:
|
|
|
|
HandleTable() {}
|
|
|
|
virtual ~HandleTable() {}
|
|
|
|
int createHandle();
|
|
|
|
void deleteHandle(int d);
|
|
|
|
File* getFile(int d);
|
|
|
|
File* getFile(const std::string& host_name);
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::vector<File*> m_files;
|
|
|
|
std::mutex m_mutex;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Core::FileSys
|