Merge pull request #149 from linkmauve/open-file-directly-fix
Don’t fail on empty filename in OpenFileDirectly, return the archive handle instead
This commit is contained in:
commit
fd7f92d242
|
@ -83,7 +83,7 @@ void OpenFileDirectly(Service::Interface* self) {
|
||||||
auto archive_id = static_cast<FileSys::Archive::IdCode>(cmd_buff[2]);
|
auto archive_id = static_cast<FileSys::Archive::IdCode>(cmd_buff[2]);
|
||||||
LowPathType archive_type = static_cast<LowPathType>(cmd_buff[3]);
|
LowPathType archive_type = static_cast<LowPathType>(cmd_buff[3]);
|
||||||
u32 archive_size = cmd_buff[4];
|
u32 archive_size = cmd_buff[4];
|
||||||
LowPathType type = static_cast<LowPathType>(cmd_buff[5]);
|
LowPathType file_type = static_cast<LowPathType>(cmd_buff[5]);
|
||||||
u32 size = cmd_buff[6];
|
u32 size = cmd_buff[6];
|
||||||
FileSys::Mode mode; mode.hex = cmd_buff[7];
|
FileSys::Mode mode; mode.hex = cmd_buff[7];
|
||||||
u32 attributes = cmd_buff[8]; // TODO(Link Mauve): do something with those attributes.
|
u32 attributes = cmd_buff[8]; // TODO(Link Mauve): do something with those attributes.
|
||||||
|
@ -96,19 +96,13 @@ void OpenFileDirectly(Service::Interface* self) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type != LowPathType::Char) {
|
|
||||||
ERROR_LOG(KERNEL, "file LowPath type other than char is currently unsupported");
|
|
||||||
cmd_buff[1] = -1;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string archive_name = GetStringFromCmdBuff(archive_pointer, archive_size);
|
std::string archive_name = GetStringFromCmdBuff(archive_pointer, archive_size);
|
||||||
std::string file_name = GetStringFromCmdBuff(pointer, size);
|
std::string file_name = GetStringFromCmdBuff(pointer, size);
|
||||||
|
|
||||||
DEBUG_LOG(KERNEL, "archive_type=%d archive_size=%d archive_data=%s"
|
DEBUG_LOG(KERNEL, "archive_type=%d archive_size=%d archive_data=%s"
|
||||||
"file_type=%d file_size=%d file_mode=%d file_attrs=%d file_data=%s",
|
"file_type=%d file_size=%d file_mode=%d file_attrs=%d file_data=%s",
|
||||||
archive_type, archive_size, archive_name.c_str(),
|
archive_type, archive_size, archive_name.c_str(),
|
||||||
type, size, mode, attributes, file_name.c_str());
|
file_type, size, mode, attributes, file_name.c_str());
|
||||||
|
|
||||||
// TODO(Link Mauve): check if we should even get a handle for the archive, and don't leak it.
|
// TODO(Link Mauve): check if we should even get a handle for the archive, and don't leak it.
|
||||||
Handle archive_handle = Kernel::OpenArchive(archive_id);
|
Handle archive_handle = Kernel::OpenArchive(archive_id);
|
||||||
|
@ -123,6 +117,11 @@ void OpenFileDirectly(Service::Interface* self) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (file_type != LowPathType::Char) {
|
||||||
|
WARN_LOG(KERNEL, "file LowPath type other than char is currently unsupported; returning archive handle instead");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Handle handle = Kernel::OpenFileFromArchive(archive_handle, file_name, mode);
|
Handle handle = Kernel::OpenFileFromArchive(archive_handle, file_name, mode);
|
||||||
if (handle) {
|
if (handle) {
|
||||||
cmd_buff[1] = 0;
|
cmd_buff[1] = 0;
|
||||||
|
|
Loading…
Reference in New Issue