mirror of
https://github.com/cemu-project/Cemu.git
synced 2024-11-22 09:09:18 +01:00
Fixes for titles in NUS format
Symlinks were not handled correctly
This commit is contained in:
parent
29c823fa1f
commit
db53f3b980
@ -686,25 +686,25 @@ bool FSTVolume::OpenFile(std::string_view path, FSTFileHandle& fileHandleOut, bo
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FSTVolume::IsDirectory(FSTFileHandle& fileHandle) const
|
||||
bool FSTVolume::IsDirectory(const FSTFileHandle& fileHandle) const
|
||||
{
|
||||
cemu_assert_debug(fileHandle.m_fstIndex < m_entries.size());
|
||||
return m_entries[fileHandle.m_fstIndex].GetType() == FSTEntry::TYPE::DIRECTORY;
|
||||
};
|
||||
|
||||
bool FSTVolume::IsFile(FSTFileHandle& fileHandle) const
|
||||
bool FSTVolume::IsFile(const FSTFileHandle& fileHandle) const
|
||||
{
|
||||
cemu_assert_debug(fileHandle.m_fstIndex < m_entries.size());
|
||||
return m_entries[fileHandle.m_fstIndex].GetType() == FSTEntry::TYPE::FILE;
|
||||
};
|
||||
|
||||
bool FSTVolume::HasLinkFlag(FSTFileHandle& fileHandle) const
|
||||
bool FSTVolume::HasLinkFlag(const FSTFileHandle& fileHandle) const
|
||||
{
|
||||
cemu_assert_debug(fileHandle.m_fstIndex < m_entries.size());
|
||||
return HAS_FLAG(m_entries[fileHandle.m_fstIndex].GetFlags(), FSTEntry::FLAGS::FLAG_LINK);
|
||||
};
|
||||
|
||||
std::string_view FSTVolume::GetName(FSTFileHandle& fileHandle) const
|
||||
std::string_view FSTVolume::GetName(const FSTFileHandle& fileHandle) const
|
||||
{
|
||||
if (fileHandle.m_fstIndex > m_entries.size())
|
||||
return "";
|
||||
@ -712,7 +712,7 @@ std::string_view FSTVolume::GetName(FSTFileHandle& fileHandle) const
|
||||
return entryName;
|
||||
}
|
||||
|
||||
std::string FSTVolume::GetPath(FSTFileHandle& fileHandle) const
|
||||
std::string FSTVolume::GetPath(const FSTFileHandle& fileHandle) const
|
||||
{
|
||||
std::string path;
|
||||
auto& entry = m_entries[fileHandle.m_fstIndex];
|
||||
@ -743,7 +743,7 @@ std::string FSTVolume::GetPath(FSTFileHandle& fileHandle) const
|
||||
return path;
|
||||
}
|
||||
|
||||
uint32 FSTVolume::GetFileSize(FSTFileHandle& fileHandle) const
|
||||
uint32 FSTVolume::GetFileSize(const FSTFileHandle& fileHandle) const
|
||||
{
|
||||
if (m_entries[fileHandle.m_fstIndex].GetType() != FSTEntry::TYPE::FILE)
|
||||
return 0;
|
||||
@ -994,6 +994,7 @@ bool FSTVolume::OpenDirectoryIterator(std::string_view path, FSTDirectoryIterato
|
||||
if (!IsDirectory(fileHandle))
|
||||
return false;
|
||||
auto const& fstEntry = m_entries[fileHandle.m_fstIndex];
|
||||
directoryIteratorOut.dirHandle = fileHandle;
|
||||
directoryIteratorOut.startIndex = fileHandle.m_fstIndex + 1;
|
||||
directoryIteratorOut.endIndex = fstEntry.dirInfo.endIndex;
|
||||
directoryIteratorOut.currentIndex = directoryIteratorOut.startIndex;
|
||||
|
@ -11,7 +11,13 @@ private:
|
||||
struct FSTDirectoryIterator
|
||||
{
|
||||
friend class FSTVolume;
|
||||
|
||||
const FSTFileHandle& GetDirHandle() const
|
||||
{
|
||||
return dirHandle;
|
||||
}
|
||||
private:
|
||||
FSTFileHandle dirHandle;
|
||||
uint32 startIndex;
|
||||
uint32 endIndex;
|
||||
uint32 currentIndex;
|
||||
@ -43,15 +49,15 @@ public:
|
||||
bool OpenFile(std::string_view path, FSTFileHandle& fileHandleOut, bool openOnlyFiles = false);
|
||||
|
||||
// file and directory functions
|
||||
bool IsDirectory(FSTFileHandle& fileHandle) const;
|
||||
bool IsFile(FSTFileHandle& fileHandle) const;
|
||||
bool HasLinkFlag(FSTFileHandle& fileHandle) const;
|
||||
bool IsDirectory(const FSTFileHandle& fileHandle) const;
|
||||
bool IsFile(const FSTFileHandle& fileHandle) const;
|
||||
bool HasLinkFlag(const FSTFileHandle& fileHandle) const;
|
||||
|
||||
std::string_view GetName(FSTFileHandle& fileHandle) const;
|
||||
std::string GetPath(FSTFileHandle& fileHandle) const;
|
||||
std::string_view GetName(const FSTFileHandle& fileHandle) const;
|
||||
std::string GetPath(const FSTFileHandle& fileHandle) const;
|
||||
|
||||
// file functions
|
||||
uint32 GetFileSize(FSTFileHandle& fileHandle) const;
|
||||
uint32 GetFileSize(const FSTFileHandle& fileHandle) const;
|
||||
uint32 ReadFile(FSTFileHandle& fileHandle, uint32 offset, uint32 size, void* dataOut);
|
||||
|
||||
// directory iterator
|
||||
|
@ -128,7 +128,7 @@ class fscDeviceWUDC : public fscDeviceC
|
||||
if (HAS_FLAG(accessFlags, FSC_ACCESS_FLAG::OPEN_FILE))
|
||||
{
|
||||
FSTFileHandle fstFileHandle;
|
||||
if (mountedVolume->OpenFile(path, fstFileHandle, true))
|
||||
if (mountedVolume->OpenFile(path, fstFileHandle, true) && !mountedVolume->HasLinkFlag(fstFileHandle))
|
||||
{
|
||||
*fscStatus = FSC_STATUS_OK;
|
||||
return new FSCDeviceWudFileCtx(mountedVolume, fstFileHandle);
|
||||
@ -137,7 +137,7 @@ class fscDeviceWUDC : public fscDeviceC
|
||||
if (HAS_FLAG(accessFlags, FSC_ACCESS_FLAG::OPEN_DIR))
|
||||
{
|
||||
FSTDirectoryIterator dirIterator;
|
||||
if (mountedVolume->OpenDirectoryIterator(path, dirIterator))
|
||||
if (mountedVolume->OpenDirectoryIterator(path, dirIterator) && !mountedVolume->HasLinkFlag(dirIterator.GetDirHandle()))
|
||||
{
|
||||
*fscStatus = FSC_STATUS_OK;
|
||||
return new FSCDeviceWudFileCtx(mountedVolume, dirIterator);
|
||||
|
@ -136,8 +136,8 @@ private:
|
||||
// this is to stay consistent with previous Cemu versions which did not support NUS format at all
|
||||
TitleInfo::TitleDataFormat currentFormat = currentTitle.GetFormat();
|
||||
TitleInfo::TitleDataFormat newFormat = newTitle.GetFormat();
|
||||
if (currentFormat != newFormat && currentFormat == TitleInfo::TitleDataFormat::NUS)
|
||||
return true;
|
||||
if (currentFormat != TitleInfo::TitleDataFormat::NUS && newFormat == TitleInfo::TitleDataFormat::NUS)
|
||||
return false;
|
||||
return true;
|
||||
};
|
||||
|
||||
|
@ -1286,7 +1286,11 @@ bool DownloadManager::asyncPackageInstallRecursiveExtractFiles(Package* package,
|
||||
setPackageError(package, "Internal error");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fstVolume->HasLinkFlag(dirItr.GetDirHandle()))
|
||||
{
|
||||
cemu_assert_suspicious();
|
||||
return true;
|
||||
}
|
||||
FSTFileHandle itr;
|
||||
while (fstVolume->Next(dirItr, itr))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user