fs: Remove some unnecessary string conversions
This commit is contained in:
parent
10a7110c7d
commit
3c8b3f9a29
|
@ -131,14 +131,9 @@ File* HandleTable::GetFile(int d) {
|
||||||
return m_files.at(d - RESERVED_HANDLES);
|
return m_files.at(d - RESERVED_HANDLES);
|
||||||
}
|
}
|
||||||
|
|
||||||
File* HandleTable::getFile(const std::string& host_name) {
|
File* HandleTable::GetFile(const std::filesystem::path& host_name) {
|
||||||
std::scoped_lock lock{m_mutex};
|
const auto it = std::ranges::find(m_files, host_name, &File::m_host_name);
|
||||||
for (auto* file : m_files) {
|
return it == m_files.end() ? nullptr : *it;
|
||||||
if (file != nullptr && file->m_host_name == host_name) {
|
|
||||||
return file;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Core::FileSys
|
} // namespace Core::FileSys
|
||||||
|
|
|
@ -54,7 +54,7 @@ struct DirEntry {
|
||||||
struct File {
|
struct File {
|
||||||
std::atomic_bool is_opened{};
|
std::atomic_bool is_opened{};
|
||||||
std::atomic_bool is_directory{};
|
std::atomic_bool is_directory{};
|
||||||
std::string m_host_name;
|
std::filesystem::path m_host_name;
|
||||||
std::string m_guest_name;
|
std::string m_guest_name;
|
||||||
Common::FS::IOFile f;
|
Common::FS::IOFile f;
|
||||||
std::vector<DirEntry> dirents;
|
std::vector<DirEntry> dirents;
|
||||||
|
@ -70,7 +70,7 @@ public:
|
||||||
int CreateHandle();
|
int CreateHandle();
|
||||||
void DeleteHandle(int d);
|
void DeleteHandle(int d);
|
||||||
File* GetFile(int d);
|
File* GetFile(int d);
|
||||||
File* getFile(const std::string& host_name);
|
File* GetFile(const std::filesystem::path& host_name);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<File*> m_files;
|
std::vector<File*> m_files;
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
namespace Libraries::Kernel {
|
namespace Libraries::Kernel {
|
||||||
|
|
||||||
std::vector<Core::FileSys::DirEntry> GetDirectoryEntries(const std::string& path) {
|
std::vector<Core::FileSys::DirEntry> GetDirectoryEntries(const std::filesystem::path& path) {
|
||||||
std::vector<Core::FileSys::DirEntry> files;
|
std::vector<Core::FileSys::DirEntry> files;
|
||||||
for (const auto& entry : std::filesystem::directory_iterator(path)) {
|
for (const auto& entry : std::filesystem::directory_iterator(path)) {
|
||||||
auto& dir_entry = files.emplace_back();
|
auto& dir_entry = files.emplace_back();
|
||||||
|
@ -58,7 +58,7 @@ int PS4_SYSV_ABI sceKernelOpen(const char* path, int flags, u16 mode) {
|
||||||
if (directory) {
|
if (directory) {
|
||||||
file->is_directory = true;
|
file->is_directory = true;
|
||||||
file->m_guest_name = path;
|
file->m_guest_name = path;
|
||||||
file->m_host_name = mnt->GetHostPath(file->m_guest_name).string();
|
file->m_host_name = mnt->GetHostPath(file->m_guest_name);
|
||||||
if (!std::filesystem::is_directory(file->m_host_name)) { // directory doesn't exist
|
if (!std::filesystem::is_directory(file->m_host_name)) { // directory doesn't exist
|
||||||
h->DeleteHandle(handle);
|
h->DeleteHandle(handle);
|
||||||
return ORBIS_KERNEL_ERROR_ENOTDIR;
|
return ORBIS_KERNEL_ERROR_ENOTDIR;
|
||||||
|
@ -72,7 +72,7 @@ int PS4_SYSV_ABI sceKernelOpen(const char* path, int flags, u16 mode) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
file->m_guest_name = path;
|
file->m_guest_name = path;
|
||||||
file->m_host_name = mnt->GetHostPath(file->m_guest_name).string();
|
file->m_host_name = mnt->GetHostPath(file->m_guest_name);
|
||||||
int e = 0;
|
int e = 0;
|
||||||
if (read) {
|
if (read) {
|
||||||
e = file->f.Open(file->m_host_name, Common::FS::FileAccessMode::Read);
|
e = file->f.Open(file->m_host_name, Common::FS::FileAccessMode::Read);
|
||||||
|
@ -174,7 +174,7 @@ int PS4_SYSV_ABI sceKernelUnlink(const char* path) {
|
||||||
return SCE_KERNEL_ERROR_EPERM;
|
return SCE_KERNEL_ERROR_EPERM;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* file = h->getFile(host_path.string());
|
auto* file = h->GetFile(host_path);
|
||||||
if (file != nullptr) {
|
if (file != nullptr) {
|
||||||
file->f.Unlink();
|
file->f.Unlink();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue