many more optimisations. cleaned up fs code. bug fixes etc (see below).

- fix usb using the wrong year when polling the timestamp.
- fs file/dir has been re-written to allow for simplified calling and remove the need of manually closing.
- add SetSize for stdio by using ftruncate.
- don't truncate the file when opened in stdio.
- add getcount api for stdio.
- display file/dir count in filebrowser for non-native fs.
- allow hash to be used on non-native fs.
- slightly optimise nro parsing by manually calculating nro size rather than doing an os call.
- slightly optimise nro parsing by keeping the fs struct alive between calls, rather than creating a new one on the stack.
- fix filebrowser peeking into zip files that are stored on non-sd fs.
- set the timestamp of a file moved to a stdio location (cut/paste).
- slightly optimise daybreak update folder detection by skipping opening/polling the dir size.
- set the fullpath of the file thats being hashed in progress box.
This commit is contained in:
ITotalJustice
2025-05-26 17:06:04 +01:00
parent 3e3ec71329
commit a9931a975d
23 changed files with 390 additions and 387 deletions

View File

@@ -2,29 +2,13 @@
namespace sphaira::yati::source {
File::File(FsFileSystem* fs, const fs::FsPath& path) {
if (fs) {
m_fs = std::make_unique<fs::FsNative>(fs, false);
} else {
m_fs = std::make_unique<fs::FsStdio>();
}
File::File(fs::Fs* fs, const fs::FsPath& path) : m_fs{fs} {
m_open_result = m_fs->OpenFile(path, FsOpenMode_Read, std::addressof(m_file));
}
File::File(const fs::FsPath& path) : File{nullptr, path} {
}
File::~File() {
if (R_SUCCEEDED(GetOpenResult())) {
m_fs->FileClose(std::addressof(m_file));
}
}
Result File::Read(void* buf, s64 off, s64 size, u64* bytes_read) {
R_TRY(GetOpenResult());
return m_fs->FileRead(std::addressof(m_file), off, buf, size, 0, bytes_read);
return m_file.Read(off, buf, size, 0, bytes_read);
}
} // namespace sphaira::yati::source

View File

@@ -3,29 +3,13 @@
namespace sphaira::yati::source {
StreamFile::StreamFile(FsFileSystem* fs, const fs::FsPath& path) {
if (fs) {
m_fs = std::make_unique<fs::FsNative>(fs, false);
} else {
m_fs = std::make_unique<fs::FsStdio>();
}
StreamFile::StreamFile(fs::Fs* fs, const fs::FsPath& path) : m_fs{fs} {
m_open_result = m_fs->OpenFile(path, FsOpenMode_Read, std::addressof(m_file));
}
StreamFile::StreamFile(const fs::FsPath& path) : StreamFile{nullptr, path} {
}
StreamFile::~StreamFile() {
if (R_SUCCEEDED(GetOpenResult())) {
m_fs->FileClose(std::addressof(m_file));
}
}
Result StreamFile::ReadChunk(void* buf, s64 size, u64* bytes_read) {
R_TRY(GetOpenResult());
const auto rc = m_fs->FileRead(std::addressof(m_file), m_offset, buf, size, 0, bytes_read);
const auto rc = m_file.Read(m_offset, buf, size, 0, bytes_read);
m_offset += *bytes_read;
return rc;
}

View File

@@ -1378,15 +1378,11 @@ Result InstallInternalStream(ui::ProgressBox* pbox, std::shared_ptr<source::Base
} // namespace
Result InstallFromFile(ui::ProgressBox* pbox, FsFileSystem* fs, const fs::FsPath& path, const ConfigOverride& override) {
Result InstallFromFile(ui::ProgressBox* pbox, fs::Fs* fs, const fs::FsPath& path, const ConfigOverride& override) {
return InstallFromSource(pbox, std::make_shared<source::File>(fs, path), path, override);
// return InstallFromSource(pbox, std::make_shared<source::StreamFile>(fs, path), path, override);
}
Result InstallFromFile(ui::ProgressBox* pbox, const fs::FsPath& path, const ConfigOverride& override) {
return InstallFromFile(pbox, nullptr, path, override);
}
Result InstallFromSource(ui::ProgressBox* pbox, std::shared_ptr<source::Base> source, const fs::FsPath& path, const ConfigOverride& override) {
const auto ext = std::strrchr(path.s, '.');
R_UNLESS(ext, Result_ContainerNotFound);