From 45103ec496670e67b9e80a3132104cee899f5cf0 Mon Sep 17 00:00:00 2001 From: Francisco Javier Trujillo Mata Date: Tue, 23 Mar 2021 14:10:07 +0100 Subject: [PATCH] HostFS: Add mkdir and rmdir support --- pcsx2/IopBios.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/pcsx2/IopBios.cpp b/pcsx2/IopBios.cpp index 9ee8fd034c..2645a23877 100644 --- a/pcsx2/IopBios.cpp +++ b/pcsx2/IopBios.cpp @@ -413,6 +413,27 @@ namespace ioman { return 0; } + int mkdir_HLE() + { + const std::string full_path = Ra0; + + if (is_host(full_path)) + { + const std::string path = full_path.substr(full_path.find(':') + 1); + int tmpError; +#ifdef _WIN32 + tmpError = ::mkdir(host_path(path).data()); +#else + tmpError = ::mkdir(host_path(path).data(), S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH); +#endif + v0 = HostFile::translate_error(tmpError); + pc = ra; + return 1; + } + + return 0; + } + int read_HLE() { s32 fd = a0; @@ -440,6 +461,21 @@ namespace ioman { return 0; } + int rmdir_HLE() + { + const std::string full_path = Ra0; + + if (is_host(full_path)) + { + const std::string path = full_path.substr(full_path.find(':') + 1); + v0 = HostFile::translate_error(::rmdir(host_path(path).data())); + pc = ra; + return 1; + } + + return 0; + } + int write_HLE() { s32 fd = a0; @@ -670,6 +706,8 @@ irxHLE irxImportHLE(const std::string &libname, u16 index) EXPORT_H( 6, read) EXPORT_H( 7, write) EXPORT_H( 8, lseek) + EXPORT_H( 11, mkdir) + EXPORT_H( 12, rmdir) END_MODULE return 0;