Added CreateFile to the FS_USER service
Tested with a local branch of hwtests.
This commit is contained in:
parent
ae3c6e82f7
commit
c7facb0ab3
8 changed files with 89 additions and 1 deletions
|
@ -208,6 +208,14 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual bool DeleteDirectory(const FileSys::Path& path) const = 0;
|
virtual bool DeleteDirectory(const FileSys::Path& path) const = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a file specified by its path
|
||||||
|
* @param path Path relative to the Archive
|
||||||
|
* @param size The size of the new file, filled with zeroes
|
||||||
|
* @return Whether creation of directory succeeded
|
||||||
|
*/
|
||||||
|
virtual bool CreateFile(const Path& path, const u32 size) const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a directory specified by its path
|
* Create a directory specified by its path
|
||||||
* @param path Path relative to the archive
|
* @param path Path relative to the archive
|
||||||
|
|
|
@ -58,6 +58,11 @@ bool Archive_RomFS::DeleteDirectory(const FileSys::Path& path) const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Archive_RomFS::CreateFile(const Path& path, const u32 size) const {
|
||||||
|
ERROR_LOG(FILESYS, "Attempted to create a file in ROMFS.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a directory specified by its path
|
* Create a directory specified by its path
|
||||||
* @param path Path relative to the archive
|
* @param path Path relative to the archive
|
||||||
|
|
|
@ -43,6 +43,14 @@ public:
|
||||||
*/
|
*/
|
||||||
bool DeleteFile(const FileSys::Path& path) const override;
|
bool DeleteFile(const FileSys::Path& path) const override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a file specified by its path
|
||||||
|
* @param path Path relative to the Archive
|
||||||
|
* @param size The size of the new file, filled with zeroes
|
||||||
|
* @return Whether creation of directory succeeded
|
||||||
|
*/
|
||||||
|
bool CreateFile(const Path& path, const u32 size) const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rename a File specified by its path
|
* Rename a File specified by its path
|
||||||
* @param src_path Source path relative to the archive
|
* @param src_path Source path relative to the archive
|
||||||
|
|
|
@ -79,6 +79,11 @@ bool Archive_SDMC::DeleteDirectory(const FileSys::Path& path) const {
|
||||||
return FileUtil::DeleteDir(GetMountPoint() + path.AsString());
|
return FileUtil::DeleteDir(GetMountPoint() + path.AsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Archive_SDMC::CreateFile(const FileSys::Path& path, const u32 size) const {
|
||||||
|
FileUtil::IOFile file(GetMountPoint() + path.AsString(), "wb");
|
||||||
|
return file.Seek(size, SEEK_SET);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a directory specified by its path
|
* Create a directory specified by its path
|
||||||
* @param path Path relative to the archive
|
* @param path Path relative to the archive
|
||||||
|
|
|
@ -62,6 +62,14 @@ public:
|
||||||
*/
|
*/
|
||||||
bool DeleteDirectory(const FileSys::Path& path) const override;
|
bool DeleteDirectory(const FileSys::Path& path) const override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a file specified by its path
|
||||||
|
* @param path Path relative to the Archive
|
||||||
|
* @param size The size of the new file, filled with zeroes
|
||||||
|
* @return Whether creation of directory succeeded
|
||||||
|
*/
|
||||||
|
bool CreateFile(const Path& path, const u32 size) const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a directory specified by its path
|
* Create a directory specified by its path
|
||||||
* @param path Path relative to the archive
|
* @param path Path relative to the archive
|
||||||
|
|
|
@ -377,6 +377,16 @@ ResultCode DeleteDirectoryFromArchive(Handle archive_handle, const FileSys::Path
|
||||||
ErrorSummary::Canceled, ErrorLevel::Status);
|
ErrorSummary::Canceled, ErrorLevel::Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ResultCode CreateFileFromArchive(Handle archive_handle, const FileSys::Path& path, const u32 file_size) {
|
||||||
|
Archive* archive = Kernel::g_object_pool.GetFast<Archive>(archive_handle);
|
||||||
|
if (archive == nullptr)
|
||||||
|
return InvalidHandle(ErrorModule::FS);
|
||||||
|
if (archive->backend->CreateFile(path, file_size))
|
||||||
|
return RESULT_SUCCESS;
|
||||||
|
return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description
|
||||||
|
ErrorSummary::Canceled, ErrorLevel::Status);
|
||||||
|
}
|
||||||
|
|
||||||
ResultCode CreateDirectoryFromArchive(Handle archive_handle, const FileSys::Path& path) {
|
ResultCode CreateDirectoryFromArchive(Handle archive_handle, const FileSys::Path& path) {
|
||||||
Archive* archive = Kernel::g_object_pool.GetFast<Archive>(archive_handle);
|
Archive* archive = Kernel::g_object_pool.GetFast<Archive>(archive_handle);
|
||||||
if (archive == nullptr)
|
if (archive == nullptr)
|
||||||
|
|
|
@ -71,6 +71,15 @@ ResultCode RenameFileBetweenArchives(Handle src_archive_handle, const FileSys::P
|
||||||
*/
|
*/
|
||||||
ResultCode DeleteDirectoryFromArchive(Handle archive_handle, const FileSys::Path& path);
|
ResultCode DeleteDirectoryFromArchive(Handle archive_handle, const FileSys::Path& path);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a File from an Archive
|
||||||
|
* @param archive_handle Handle to an open Archive object
|
||||||
|
* @param path Path to the File inside of the Archive
|
||||||
|
* @param file_size The size of the new file, filled with zeroes
|
||||||
|
* @return Whether creation of directory succeeded
|
||||||
|
*/
|
||||||
|
ResultCode CreateFileFromArchive(Handle archive_handle, const FileSys::Path& path, const u32 file_size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a Directory from an Archive
|
* Create a Directory from an Archive
|
||||||
* @param archive_handle Handle to an open Archive object
|
* @param archive_handle Handle to an open Archive object
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
#include "core/hle/service/fs_user.h"
|
#include "core/hle/service/fs_user.h"
|
||||||
#include "core/settings.h"
|
#include "core/settings.h"
|
||||||
|
|
||||||
|
#include "common/file_util.h"
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Namespace FS_User
|
// Namespace FS_User
|
||||||
|
|
||||||
|
@ -237,6 +239,39 @@ void DeleteDirectory(Service::Interface* self) {
|
||||||
DEBUG_LOG(KERNEL, "called");
|
DEBUG_LOG(KERNEL, "called");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* FS_User::CreateFile service function
|
||||||
|
* Inputs:
|
||||||
|
* 2 : Archive handle lower word
|
||||||
|
* 3 : Archive handle upper word
|
||||||
|
* 4 : File path string type
|
||||||
|
* 5 : File path string size
|
||||||
|
* 7 : File size (filled with zeroes)
|
||||||
|
* 10: File path string data
|
||||||
|
* Outputs:
|
||||||
|
* 1 : Result of function, 0 on success, otherwise error code
|
||||||
|
*/
|
||||||
|
static void CreateFile(Service::Interface* self) {
|
||||||
|
u32* cmd_buff = Service::GetCommandBuffer();
|
||||||
|
|
||||||
|
// TODO: cmd_buff[2], aka archive handle lower word, isn't used according to
|
||||||
|
// 3dmoo's or ctrulib's implementations. Triple check if it's really the case.
|
||||||
|
Handle archive_handle = static_cast<Handle>(cmd_buff[3]);
|
||||||
|
auto filename_type = static_cast<FileSys::LowPathType>(cmd_buff[4]);
|
||||||
|
u32 filename_size = cmd_buff[5];
|
||||||
|
u32 file_size = cmd_buff[7];
|
||||||
|
u32 filename_ptr = cmd_buff[10];
|
||||||
|
|
||||||
|
FileSys::Path file_path(filename_type, filename_size, filename_ptr);
|
||||||
|
|
||||||
|
DEBUG_LOG(KERNEL, "type=%d size=%d data=%s", filename_type, filename_size, file_path.DebugStr().c_str());
|
||||||
|
|
||||||
|
|
||||||
|
cmd_buff[1] = Kernel::CreateFileFromArchive(archive_handle, file_path, file_size).raw;
|
||||||
|
|
||||||
|
DEBUG_LOG(KERNEL, "called");
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* FS_User::CreateDirectory service function
|
* FS_User::CreateDirectory service function
|
||||||
* Inputs:
|
* Inputs:
|
||||||
|
@ -401,7 +436,7 @@ const Interface::FunctionInfo FunctionTable[] = {
|
||||||
{0x08050244, RenameFile, "RenameFile"},
|
{0x08050244, RenameFile, "RenameFile"},
|
||||||
{0x08060142, DeleteDirectory, "DeleteDirectory"},
|
{0x08060142, DeleteDirectory, "DeleteDirectory"},
|
||||||
{0x08070142, nullptr, "DeleteDirectoryRecursively"},
|
{0x08070142, nullptr, "DeleteDirectoryRecursively"},
|
||||||
{0x08080202, nullptr, "CreateFile"},
|
{0x08080202, CreateFile, "CreateFile"},
|
||||||
{0x08090182, CreateDirectory, "CreateDirectory"},
|
{0x08090182, CreateDirectory, "CreateDirectory"},
|
||||||
{0x080A0244, RenameDirectory, "RenameDirectory"},
|
{0x080A0244, RenameDirectory, "RenameDirectory"},
|
||||||
{0x080B0102, OpenDirectory, "OpenDirectory"},
|
{0x080B0102, OpenDirectory, "OpenDirectory"},
|
||||||
|
|
Loading…
Reference in a new issue