mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-05-24 04:15:01 +00:00
common: Rewrite logging based on cut down citra logger (#86)
* common: Rewrite logging based on cut down Citra logger * code: Misc fixes * core: Bring back tls handler * linker: Cleanup * config: Remove log level * logging: Enable console output by default * core: Fix windows build
This commit is contained in:
parent
b3084646a8
commit
79d6c8a377
70 changed files with 3212 additions and 1541 deletions
|
@ -8,21 +8,24 @@ namespace Core::FileSys {
|
|||
|
||||
constexpr int RESERVED_HANDLES = 3; // First 3 handles are stdin,stdout,stderr
|
||||
|
||||
void MntPoints::mount(const std::string& host_folder, const std::string& guest_folder) {
|
||||
void MntPoints::Mount(const std::filesystem::path& host_folder, const std::string& guest_folder) {
|
||||
std::scoped_lock lock{m_mutex};
|
||||
|
||||
MntPair pair;
|
||||
pair.host_path = host_folder;
|
||||
pair.host_path = host_folder.string();
|
||||
pair.guest_path = guest_folder;
|
||||
|
||||
m_mnt_pairs.push_back(pair);
|
||||
}
|
||||
void MntPoints::unmount(const std::string& path) {} // TODO!
|
||||
void MntPoints::unmountAll() {
|
||||
|
||||
void MntPoints::Unmount(const std::string& path) {} // TODO!
|
||||
|
||||
void MntPoints::UnmountAll() {
|
||||
std::scoped_lock lock{m_mutex};
|
||||
m_mnt_pairs.clear();
|
||||
}
|
||||
std::string MntPoints::getHostDirectory(const std::string& guest_directory) {
|
||||
|
||||
std::string MntPoints::GetHostDirectory(const std::string& guest_directory) {
|
||||
std::scoped_lock lock{m_mutex};
|
||||
for (auto& pair : m_mnt_pairs) {
|
||||
if (pair.guest_path.starts_with(guest_directory)) {
|
||||
|
@ -38,7 +41,8 @@ std::string MntPoints::getHostDirectory(const std::string& guest_directory) {
|
|||
}
|
||||
return "";
|
||||
}
|
||||
std::string MntPoints::getHostFile(const std::string& guest_file) {
|
||||
|
||||
std::string MntPoints::GetHostFile(const std::string& guest_file) {
|
||||
std::scoped_lock lock{m_mutex};
|
||||
|
||||
for (auto& pair : m_mnt_pairs) {
|
||||
|
@ -52,11 +56,13 @@ std::string MntPoints::getHostFile(const std::string& guest_file) {
|
|||
}
|
||||
return "";
|
||||
}
|
||||
int HandleTable::createHandle() {
|
||||
|
||||
int HandleTable::CreateHandle() {
|
||||
std::scoped_lock lock{m_mutex};
|
||||
|
||||
auto* file = new File{};
|
||||
file->isDirectory = false;
|
||||
file->isOpened = false;
|
||||
file->is_directory = false;
|
||||
file->is_opened = false;
|
||||
|
||||
int existingFilesNum = m_files.size();
|
||||
|
||||
|
@ -68,19 +74,20 @@ int HandleTable::createHandle() {
|
|||
}
|
||||
|
||||
m_files.push_back(file);
|
||||
|
||||
return m_files.size() + RESERVED_HANDLES - 1;
|
||||
}
|
||||
void HandleTable::deleteHandle(int d) {
|
||||
|
||||
void HandleTable::DeleteHandle(int d) {
|
||||
std::scoped_lock lock{m_mutex};
|
||||
delete m_files.at(d - RESERVED_HANDLES);
|
||||
m_files[d - RESERVED_HANDLES] = nullptr;
|
||||
}
|
||||
|
||||
File* HandleTable::getFile(int d) {
|
||||
File* HandleTable::GetFile(int d) {
|
||||
std::scoped_lock lock{m_mutex};
|
||||
return m_files.at(d - RESERVED_HANDLES);
|
||||
}
|
||||
|
||||
File* HandleTable::getFile(const std::string& host_name) {
|
||||
std::scoped_lock lock{m_mutex};
|
||||
for (auto* file : m_files) {
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#include <mutex>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "common/fs_file.h"
|
||||
#include "common/io_file.h"
|
||||
|
||||
namespace Core::FileSys {
|
||||
|
@ -21,11 +20,12 @@ public:
|
|||
|
||||
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);
|
||||
std::string getHostFile(const std::string& guest_file);
|
||||
|
||||
void Mount(const std::filesystem::path& host_folder, const std::string& guest_folder);
|
||||
void Unmount(const std::string& path);
|
||||
void UnmountAll();
|
||||
std::string GetHostDirectory(const std::string& guest_directory);
|
||||
std::string GetHostFile(const std::string& guest_file);
|
||||
|
||||
private:
|
||||
std::vector<MntPair> m_mnt_pairs;
|
||||
|
@ -33,22 +33,24 @@ private:
|
|||
};
|
||||
|
||||
struct File {
|
||||
std::atomic_bool isOpened;
|
||||
std::atomic_bool isDirectory;
|
||||
std::atomic_bool is_opened{};
|
||||
std::atomic_bool is_directory{};
|
||||
std::string m_host_name;
|
||||
std::string m_guest_name;
|
||||
IOFile f;
|
||||
Common::FS::IOFile f;
|
||||
// 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);
|
||||
HandleTable() = default;
|
||||
virtual ~HandleTable() = default;
|
||||
|
||||
int CreateHandle();
|
||||
void DeleteHandle(int d);
|
||||
File* GetFile(int d);
|
||||
File* getFile(const std::string& host_name);
|
||||
|
||||
private:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue