mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-08-05 23:58:59 +00:00
DiscIO: Use Common::Lazy for loading filesystems
This simplifies FileMonitor a lot and also lets us clean up FilesystemPanel.
This commit is contained in:
parent
0d07821935
commit
38304da947
21 changed files with 182 additions and 172 deletions
|
@ -10,23 +10,24 @@
|
|||
namespace DiscIO
|
||||
{
|
||||
std::unique_ptr<VolumeFileBlobReader> VolumeFileBlobReader::Create(const Volume& volume,
|
||||
const FileSystem& file_system,
|
||||
const Partition& partition,
|
||||
const std::string& file_path)
|
||||
{
|
||||
if (!file_system.IsValid())
|
||||
const FileSystem* file_system = volume.GetFileSystem(partition);
|
||||
if (!file_system)
|
||||
return nullptr;
|
||||
|
||||
std::unique_ptr<FileInfo> file_info = file_system.FindFileInfo(file_path);
|
||||
std::unique_ptr<FileInfo> file_info = file_system->FindFileInfo(file_path);
|
||||
if (!file_info || file_info->IsDirectory())
|
||||
return nullptr;
|
||||
|
||||
return std::unique_ptr<VolumeFileBlobReader>{
|
||||
new VolumeFileBlobReader(volume, file_system, std::move(file_info))};
|
||||
new VolumeFileBlobReader(volume, partition, std::move(file_info))};
|
||||
}
|
||||
|
||||
VolumeFileBlobReader::VolumeFileBlobReader(const Volume& volume, const FileSystem& file_system,
|
||||
VolumeFileBlobReader::VolumeFileBlobReader(const Volume& volume, const Partition& partition,
|
||||
std::unique_ptr<FileInfo> file_info)
|
||||
: m_volume(volume), m_file_system(file_system), m_file_info(std::move(file_info))
|
||||
: m_volume(volume), m_partition(partition), m_file_info(std::move(file_info))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -45,7 +46,6 @@ bool VolumeFileBlobReader::Read(u64 offset, u64 length, u8* out_ptr)
|
|||
if (offset + length > m_file_info->GetSize())
|
||||
return false;
|
||||
|
||||
return m_volume.Read(m_file_info->GetOffset() + offset, length, out_ptr,
|
||||
m_file_system.GetPartition());
|
||||
return m_volume.Read(m_file_info->GetOffset() + offset, length, out_ptr, m_partition);
|
||||
}
|
||||
} // namespace
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue