summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorPierre Bourdon <delroth@gmail.com>2017-08-05 19:51:29 +0200
committerPierre Bourdon <delroth@gmail.com>2017-08-15 22:29:10 +0200
commitc14ab0dd539f552e652d842326e4e8918827ea2e (patch)
tree2d7ad594ff48248293bbddff226f1c4eb0202572 /Source
parent5a4900bc96750a6e30f5b513bb03f981bd32e4db (diff)
WFS: Implement current/home path expansion.
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/Core/IOS/WFS/WFSSRV.cpp32
-rw-r--r--Source/Core/Core/IOS/WFS/WFSSRV.h14
2 files changed, 42 insertions, 4 deletions
diff --git a/Source/Core/Core/IOS/WFS/WFSSRV.cpp b/Source/Core/Core/IOS/WFS/WFSSRV.cpp
index 5a01916d55..1f82768ad4 100644
--- a/Source/Core/Core/IOS/WFS/WFSSRV.cpp
+++ b/Source/Core/Core/IOS/WFS/WFSSRV.cpp
@@ -117,12 +117,26 @@ IPCCommandResult WFSSRV::IOCtl(const IOCtlRequest& request)
Memory::Memset(request.buffer_out, 0, request.buffer_out_size);
break;
+ case IOCTL_WFS_SET_HOMEDIR:
+ m_home_directory =
+ Memory::GetString(request.buffer_in + 2, Memory::Read_U16(request.buffer_in));
+ INFO_LOG(IOS, "IOCTL_WFS_SET_HOMEDIR: %s", m_home_directory.c_str());
+ break;
+
+ case IOCTL_WFS_CHDIR:
+ m_current_directory =
+ Memory::GetString(request.buffer_in + 2, Memory::Read_U16(request.buffer_in));
+ INFO_LOG(IOS, "IOCTL_WFS_CHDIR: %s", m_current_directory.c_str());
+ break;
+
case IOCTL_WFS_OPEN:
{
u32 mode = Memory::Read_U32(request.buffer_in);
u16 path_len = Memory::Read_U16(request.buffer_in + 0x20);
std::string path = Memory::GetString(request.buffer_in + 0x22, path_len);
+ path = ExpandPath(path);
+
u16 fd = GetNewFileDescriptor();
FileDescriptor* fd_obj = &m_fds[fd];
fd_obj->in_use = true;
@@ -190,6 +204,24 @@ IPCCommandResult WFSSRV::IOCtl(const IOCtlRequest& request)
return GetDefaultReply(return_error_code);
}
+std::string WFSSRV::ExpandPath(const std::string& path) const
+{
+ std::string expanded;
+ if (!path.empty() && path[0] == '~')
+ {
+ expanded = m_home_directory + "/" + path.substr(1);
+ }
+ else if (path.empty() || path[0] != '/')
+ {
+ expanded = m_current_directory + "/" + path;
+ }
+ else
+ {
+ expanded = path;
+ }
+ return expanded;
+}
+
WFSSRV::FileDescriptor* WFSSRV::FindFileDescriptor(u16 fd)
{
if (fd >= m_fds.size() || !m_fds[fd].in_use)
diff --git a/Source/Core/Core/IOS/WFS/WFSSRV.h b/Source/Core/Core/IOS/WFS/WFSSRV.h
index 0f4de83e3f..72432ae754 100644
--- a/Source/Core/Core/IOS/WFS/WFSSRV.h
+++ b/Source/Core/Core/IOS/WFS/WFSSRV.h
@@ -35,6 +35,12 @@ private:
// WFS device name, e.g. msc01/msc02.
std::string m_device_name;
+ // Home / current directories.
+ std::string m_home_directory;
+ std::string m_current_directory;
+
+ std::string ExpandPath(const std::string& path) const;
+
enum
{
IOCTL_WFS_INIT = 0x02,
@@ -78,13 +84,13 @@ private:
};
std::vector<FileDescriptor> m_fds;
- // List of addresses of IPC requests left hanging that need closing at
- // shutdown time.
- std::vector<u32> m_hanging;
-
FileDescriptor* FindFileDescriptor(u16 fd);
u16 GetNewFileDescriptor();
void ReleaseFileDescriptor(u16 fd);
+
+ // List of addresses of IPC requests left hanging that need closing at
+ // shutdown time.
+ std::vector<u32> m_hanging;
};
} // namespace Device
} // namespace HLE