mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-11-15 22:20:05 +00:00
FS: Implemented IFileSystem::CreateDirectory.
This commit is contained in:
parent
0485ee499f
commit
eff3f60b73
@ -18,7 +18,7 @@ std::string Disk_FileSystem::GetName() const {
|
|||||||
ResultVal<std::unique_ptr<StorageBackend>> Disk_FileSystem::OpenFile(const std::string& path,
|
ResultVal<std::unique_ptr<StorageBackend>> Disk_FileSystem::OpenFile(const std::string& path,
|
||||||
Mode mode) const {
|
Mode mode) const {
|
||||||
|
|
||||||
std::string mode_str = "";
|
std::string mode_str;
|
||||||
u32 mode_flags = static_cast<u32>(mode);
|
u32 mode_flags = static_cast<u32>(mode);
|
||||||
|
|
||||||
// Calculate the correct open mode for the file.
|
// Calculate the correct open mode for the file.
|
||||||
@ -95,8 +95,15 @@ ResultCode Disk_FileSystem::CreateFile(const std::string& path, u64 size) const
|
|||||||
return ResultCode(-1);
|
return ResultCode(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultCode Disk_FileSystem::CreateDirectory(const Path& path) const {
|
ResultCode Disk_FileSystem::CreateDirectory(const std::string& path) const {
|
||||||
LOG_WARNING(Service_FS, "(STUBBED) called");
|
// TODO(Subv): Perform path validation to prevent escaping the emulator sandbox.
|
||||||
|
std::string full_path = base_directory + path;
|
||||||
|
|
||||||
|
if (FileUtil::CreateDir(full_path)) {
|
||||||
|
return RESULT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG_CRITICAL(Service_FS, "(unreachable) Unknown error creating %s", full_path.c_str());
|
||||||
// TODO(wwylele): Use correct error code
|
// TODO(wwylele): Use correct error code
|
||||||
return ResultCode(-1);
|
return ResultCode(-1);
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ public:
|
|||||||
ResultCode DeleteDirectory(const Path& path) const override;
|
ResultCode DeleteDirectory(const Path& path) const override;
|
||||||
ResultCode DeleteDirectoryRecursively(const Path& path) const override;
|
ResultCode DeleteDirectoryRecursively(const Path& path) const override;
|
||||||
ResultCode CreateFile(const std::string& path, u64 size) const override;
|
ResultCode CreateFile(const std::string& path, u64 size) const override;
|
||||||
ResultCode CreateDirectory(const Path& path) const override;
|
ResultCode CreateDirectory(const std::string& path) const override;
|
||||||
ResultCode RenameDirectory(const Path& src_path, const Path& dest_path) const override;
|
ResultCode RenameDirectory(const Path& src_path, const Path& dest_path) const override;
|
||||||
ResultVal<std::unique_ptr<DirectoryBackend>> OpenDirectory(
|
ResultVal<std::unique_ptr<DirectoryBackend>> OpenDirectory(
|
||||||
const std::string& path) const override;
|
const std::string& path) const override;
|
||||||
|
@ -104,7 +104,7 @@ public:
|
|||||||
* @param path Path relative to the archive
|
* @param path Path relative to the archive
|
||||||
* @return Result of the operation
|
* @return Result of the operation
|
||||||
*/
|
*/
|
||||||
virtual ResultCode CreateDirectory(const Path& path) const = 0;
|
virtual ResultCode CreateDirectory(const std::string& path) const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a directory specified by its path
|
* Delete a directory specified by its path
|
||||||
|
@ -55,7 +55,7 @@ ResultCode RomFS_FileSystem::CreateFile(const std::string& path, u64 size) const
|
|||||||
return ResultCode(-1);
|
return ResultCode(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultCode RomFS_FileSystem::CreateDirectory(const Path& path) const {
|
ResultCode RomFS_FileSystem::CreateDirectory(const std::string& path) const {
|
||||||
LOG_CRITICAL(Service_FS, "Attempted to create a directory in an ROMFS archive (%s).",
|
LOG_CRITICAL(Service_FS, "Attempted to create a directory in an ROMFS archive (%s).",
|
||||||
GetName().c_str());
|
GetName().c_str());
|
||||||
// TODO(wwylele): Use correct error code
|
// TODO(wwylele): Use correct error code
|
||||||
|
@ -36,7 +36,7 @@ public:
|
|||||||
ResultCode DeleteDirectory(const Path& path) const override;
|
ResultCode DeleteDirectory(const Path& path) const override;
|
||||||
ResultCode DeleteDirectoryRecursively(const Path& path) const override;
|
ResultCode DeleteDirectoryRecursively(const Path& path) const override;
|
||||||
ResultCode CreateFile(const std::string& path, u64 size) const override;
|
ResultCode CreateFile(const std::string& path, u64 size) const override;
|
||||||
ResultCode CreateDirectory(const Path& path) const override;
|
ResultCode CreateDirectory(const std::string& path) const override;
|
||||||
ResultCode RenameDirectory(const Path& src_path, const Path& dest_path) const override;
|
ResultCode RenameDirectory(const Path& src_path, const Path& dest_path) const override;
|
||||||
ResultVal<std::unique_ptr<DirectoryBackend>> OpenDirectory(
|
ResultVal<std::unique_ptr<DirectoryBackend>> OpenDirectory(
|
||||||
const std::string& path) const override;
|
const std::string& path) const override;
|
||||||
|
@ -208,6 +208,7 @@ public:
|
|||||||
: ServiceFramework("IFileSystem"), backend(std::move(backend)) {
|
: ServiceFramework("IFileSystem"), backend(std::move(backend)) {
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
{0, &IFileSystem::CreateFile, "CreateFile"},
|
{0, &IFileSystem::CreateFile, "CreateFile"},
|
||||||
|
{2, &IFileSystem::CreateDirectory, "CreateDirectory"},
|
||||||
{7, &IFileSystem::GetEntryType, "GetEntryType"},
|
{7, &IFileSystem::GetEntryType, "GetEntryType"},
|
||||||
{8, &IFileSystem::OpenFile, "OpenFile"},
|
{8, &IFileSystem::OpenFile, "OpenFile"},
|
||||||
{9, &IFileSystem::OpenDirectory, "OpenDirectory"},
|
{9, &IFileSystem::OpenDirectory, "OpenDirectory"},
|
||||||
@ -234,6 +235,20 @@ public:
|
|||||||
rb.Push(backend->CreateFile(name, size));
|
rb.Push(backend->CreateFile(name, size));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CreateDirectory(Kernel::HLERequestContext& ctx) {
|
||||||
|
IPC::RequestParser rp{ctx};
|
||||||
|
|
||||||
|
auto file_buffer = ctx.ReadBuffer();
|
||||||
|
auto end = std::find(file_buffer.begin(), file_buffer.end(), '\0');
|
||||||
|
|
||||||
|
std::string name(file_buffer.begin(), end);
|
||||||
|
|
||||||
|
LOG_DEBUG(Service_FS, "called directory %s", name.c_str());
|
||||||
|
|
||||||
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
|
rb.Push(backend->CreateDirectory(name));
|
||||||
|
}
|
||||||
|
|
||||||
void OpenFile(Kernel::HLERequestContext& ctx) {
|
void OpenFile(Kernel::HLERequestContext& ctx) {
|
||||||
IPC::RequestParser rp{ctx};
|
IPC::RequestParser rp{ctx};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user