[SDMC] Handle ASCII paths for CreateDirectory

This commit is contained in:
wheremyfoodat 2023-08-20 16:53:06 +03:00
parent c15ef14375
commit 5106f251cf
2 changed files with 35 additions and 18 deletions

View file

@ -64,28 +64,39 @@ FileDescriptor SDMCArchive::openFile(const FSPath& path, const FilePerms& perms)
}
HorizonResult SDMCArchive::createDirectory(const FSPath& path) {
if (path.type == PathType::UTF16) {
if (!isPathSafe<PathType::UTF16>(path)) {
Helpers::panic("Unsafe path in SDMCArchive::OpenFile");
}
std::filesystem::path p = IOFile::getAppData() / "SDMC";
fs::path p = IOFile::getAppData() / "SDMC";
p += fs::path(path.utf16_string).make_preferred();
switch (path.type) {
case PathType::ASCII:
if (!isPathSafe<PathType::ASCII>(path)) {
Helpers::panic("Unsafe path in SDMCArchive::OpenFile");
}
if (fs::is_directory(p)) {
return Result::FS::AlreadyExists;
}
p += fs::path(path.string).make_preferred();
break;
if (fs::is_regular_file(p)) {
Helpers::panic("File path passed to SDMCArchive::CreateDirectory");
}
case PathType::UTF16:
if (!isPathSafe<PathType::UTF16>(path)) {
Helpers::panic("Unsafe path in SDMCArchive::OpenFile");
}
std::error_code ec;
bool success = fs::create_directory(p, ec);
return success ? Result::Success : Result::FS::UnexpectedFileOrDir;
} else {
Helpers::panic("Unimplemented SDMC::CreateDirectory path type");
p += fs::path(path.utf16_string).make_preferred();
break;
default: Helpers::panic("SDMCArchive::CreateDirectory: Failed. Path type: %d", path.type); return Result::FailurePlaceholder;
}
if (fs::is_directory(p)) {
return Result::FS::AlreadyExists;
}
if (fs::is_regular_file(p)) {
Helpers::panic("File path passed to SDMCArchive::CreateDirectory");
}
std::error_code ec;
bool success = fs::create_directory(p, ec);
return success ? Result::Success : Result::FS::UnexpectedFileOrDir;
}
Rust::Result<DirectorySession, HorizonResult> SDMCArchive::openDirectory(const FSPath& path) {

View file

@ -695,6 +695,7 @@ void RendererGL::textureCopy(u32 inputAddr, u32 outputAddr, u32 totalBytes, u32
if (inputGap != 0 || outputGap != 0) {
// Helpers::warn("Strided texture copy\n");
}
if (inputWidth != outputWidth) {
Helpers::warn("Input width does not match output width, cannot accelerate texture copy!");
return;
@ -716,7 +717,12 @@ void RendererGL::textureCopy(u32 inputAddr, u32 outputAddr, u32 totalBytes, u32
// inputHeight/outputHeight are typically set to zero so they cannot be used to get the height of the copy region
// in contrast to display transfer. Compute height manually by dividing the copy size with the copy width. The result
// is the number of vertical tiles so multiply that by eight to get the actual copy height.
const u32 copyHeight = (copySize / inputWidth) * 8;
u32 copyHeight;
if (inputWidth != 0) [[likely]] {
copyHeight = (copySize / inputWidth) * 8;
} else {
copyHeight = 0;
}
// Find the source surface.
auto srcFramebuffer = getColourBuffer(inputAddr, PICA::ColorFmt::RGBA8, copyStride, copyHeight, false);