code: Add clang-format target and CI workflow (#82)

* code: Add clang format target, rules and CI workflow

* code: Run clang format on sources
This commit is contained in:
GPUCode
2024-02-23 22:57:57 +02:00
committed by GitHub
parent 32a5ff15bb
commit 6f4c6ae0bb
90 changed files with 2942 additions and 1941 deletions

View File

@@ -4,7 +4,7 @@
namespace Core::FileSys {
constexpr int RESERVED_HANDLES = 3; // First 3 handles are stdin,stdout,stderr
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) {
std::scoped_lock lock{m_mutex};
@@ -15,7 +15,7 @@ void MntPoints::mount(const std::string& host_folder, const std::string& guest_f
m_mnt_pairs.push_back(pair);
}
void MntPoints::unmount(const std::string& path) {} // TODO!
void MntPoints::unmount(const std::string& path) {} // TODO!
void MntPoints::unmountAll() {
std::scoped_lock lock{m_mutex};
m_mnt_pairs.clear();
@@ -40,10 +40,10 @@ std::string MntPoints::getHostFile(const std::string& guest_file) {
std::scoped_lock lock{m_mutex};
for (auto& pair : m_mnt_pairs) {
//horrible code but it works :D
// horrible code but it works :D
int find = guest_file.find(pair.guest_path);
if (find == 0) {
std::string npath = guest_file.substr(pair.guest_path.size(), guest_file.size()-1);
std::string npath = guest_file.substr(pair.guest_path.size(), guest_file.size() - 1);
std::replace(pair.host_path.begin(), pair.host_path.end(), '\\', '/');
return pair.host_path + npath;
}
@@ -88,4 +88,4 @@ File* HandleTable::getFile(const std::string& host_name) {
}
return nullptr;
}
} // namespace Core::FileSys
} // namespace Core::FileSys

View File

@@ -5,16 +5,16 @@
#include <string>
#include <vector>
#include "common/fs_file.h"
#include <common/io_file.h>
#include "common/fs_file.h"
namespace Core::FileSys {
class MntPoints {
public:
public:
struct MntPair {
std::string host_path;
std::string guest_path; // e.g /app0/
std::string guest_path; // e.g /app0/
};
MntPoints() = default;
@@ -25,7 +25,7 @@ class MntPoints {
std::string getHostDirectory(const std::string& guest_directory);
std::string getHostFile(const std::string& guest_file);
private:
private:
std::vector<MntPair> m_mnt_pairs;
std::mutex m_mutex;
};
@@ -36,12 +36,12 @@ struct File {
std::string m_host_name;
std::string m_guest_name;
IOFile f;
//std::vector<Common::FS::DirEntry> dirents;
// std::vector<Common::FS::DirEntry> dirents;
u32 dirents_index;
std::mutex m_mutex;
};
class HandleTable {
public:
public:
HandleTable() {}
virtual ~HandleTable() {}
int createHandle();
@@ -49,9 +49,9 @@ class HandleTable {
File* getFile(int d);
File* getFile(const std::string& host_name);
private:
private:
std::vector<File*> m_files;
std::mutex m_mutex;
};
} // namespace Core::FileSys
} // namespace Core::FileSys