some WIP directory work on sceKernelOpen
This commit is contained in:
parent
b6e65c29fc
commit
0c705c10cb
|
@ -29,16 +29,15 @@ void MntPoints::UnmountAll() {
|
||||||
|
|
||||||
std::string MntPoints::GetHostDirectory(const std::string& guest_directory) {
|
std::string MntPoints::GetHostDirectory(const std::string& guest_directory) {
|
||||||
std::scoped_lock lock{m_mutex};
|
std::scoped_lock lock{m_mutex};
|
||||||
|
|
||||||
for (auto& pair : m_mnt_pairs) {
|
for (auto& pair : m_mnt_pairs) {
|
||||||
if (pair.guest_path.starts_with(guest_directory)) {
|
// horrible code but it works :D
|
||||||
return pair.host_path + guest_directory;
|
int find = guest_directory.find(pair.guest_path);
|
||||||
}
|
if (find == 0) {
|
||||||
}
|
std::string npath =
|
||||||
// hack for relative path , get app0 and assuming it goes from there
|
guest_directory.substr(pair.guest_path.size(), guest_directory.size() - 1);
|
||||||
for (auto& pair : m_mnt_pairs) {
|
|
||||||
if (pair.guest_path.starts_with("/app0")) {
|
|
||||||
std::replace(pair.host_path.begin(), pair.host_path.end(), '\\', '/');
|
std::replace(pair.host_path.begin(), pair.host_path.end(), '\\', '/');
|
||||||
return pair.host_path + guest_directory;
|
return pair.host_path + npath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
|
|
@ -31,11 +31,23 @@ int PS4_SYSV_ABI sceKernelOpen(const char* path, int flags, u16 mode) {
|
||||||
bool direct = (flags & ORBIS_KERNEL_O_DIRECT) != 0;
|
bool direct = (flags & ORBIS_KERNEL_O_DIRECT) != 0;
|
||||||
bool directory = (flags & ORBIS_KERNEL_O_DIRECTORY) != 0;
|
bool directory = (flags & ORBIS_KERNEL_O_DIRECTORY) != 0;
|
||||||
|
|
||||||
|
u32 handle = h->CreateHandle();
|
||||||
|
auto* file = h->GetFile(handle);
|
||||||
if (directory) {
|
if (directory) {
|
||||||
UNREACHABLE(); // not supported yet
|
file->is_directory = true;
|
||||||
|
file->m_guest_name = path;
|
||||||
|
file->m_host_name = mnt->GetHostDirectory(file->m_guest_name);
|
||||||
|
if (!std::filesystem::is_directory(file->m_host_name)) { // directory doesn't exist
|
||||||
|
UNREACHABLE(); // not supported yet
|
||||||
|
} else {
|
||||||
|
if (create) {
|
||||||
|
return handle; // dir already exists
|
||||||
|
} else {
|
||||||
|
// get dirents TODO
|
||||||
|
file->dirents_index = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
u32 handle = h->CreateHandle();
|
|
||||||
auto* file = h->GetFile(handle);
|
|
||||||
file->m_guest_name = path;
|
file->m_guest_name = path;
|
||||||
file->m_host_name = mnt->GetHostFile(file->m_guest_name);
|
file->m_host_name = mnt->GetHostFile(file->m_guest_name);
|
||||||
if (read) {
|
if (read) {
|
||||||
|
@ -49,10 +61,9 @@ int PS4_SYSV_ABI sceKernelOpen(const char* path, int flags, u16 mode) {
|
||||||
h->DeleteHandle(handle);
|
h->DeleteHandle(handle);
|
||||||
return SCE_KERNEL_ERROR_EACCES;
|
return SCE_KERNEL_ERROR_EACCES;
|
||||||
}
|
}
|
||||||
file->is_opened = true;
|
|
||||||
return handle;
|
|
||||||
}
|
}
|
||||||
return -1; // dummy
|
file->is_opened = true;
|
||||||
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PS4_SYSV_ABI posix_open(const char* path, int flags, /* SceKernelMode*/ u16 mode) {
|
int PS4_SYSV_ABI posix_open(const char* path, int flags, /* SceKernelMode*/ u16 mode) {
|
||||||
|
|
Loading…
Reference in New Issue