mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-15 11:03:00 +01:00
Fix issues with file finding on Linux
This commit is contained in:
@@ -74,7 +74,7 @@ static SourceInfo ParseSource(std::string_view source)
|
||||
|
||||
auto env = GetContext()->GetPlatformEnvironment();
|
||||
auto dataPath = env->GetDirectoryPath(DIRBASE::RCT1, DIRID::DATA);
|
||||
info.Path = Path::Combine(dataPath, name);
|
||||
info.Path = Path::ResolveCasing(Path::Combine(dataPath, name));
|
||||
}
|
||||
else if (String::StartsWith(source, "$RCT2:DATA/"))
|
||||
{
|
||||
@@ -88,7 +88,7 @@ static SourceInfo ParseSource(std::string_view source)
|
||||
|
||||
auto env = GetContext()->GetPlatformEnvironment();
|
||||
auto dataPath = env->GetDirectoryPath(DIRBASE::RCT2, DIRID::DATA);
|
||||
info.Path = Path::Combine(dataPath, name);
|
||||
info.Path = Path::ResolveCasing(Path::Combine(dataPath, name));
|
||||
}
|
||||
else if (String::StartsWith(source, "$["))
|
||||
{
|
||||
@@ -191,8 +191,11 @@ void AudioSampleTable::Unload()
|
||||
{
|
||||
for (auto& entry : _entries)
|
||||
{
|
||||
entry.Source->Release();
|
||||
entry.Source = nullptr;
|
||||
if (entry.Source != nullptr)
|
||||
{
|
||||
entry.Source->Release();
|
||||
entry.Source = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -320,19 +320,25 @@ std::vector<uint8_t> ObjectAsset::GetData() const
|
||||
|
||||
std::unique_ptr<IStream> ObjectAsset::GetStream() const
|
||||
{
|
||||
if (_zipPath.empty())
|
||||
try
|
||||
{
|
||||
return std::make_unique<FileStream>(_path, FILE_MODE_OPEN);
|
||||
}
|
||||
|
||||
auto zipArchive = Zip::TryOpen(_zipPath, ZIP_ACCESS::READ);
|
||||
if (zipArchive != nullptr)
|
||||
{
|
||||
auto stream = zipArchive->GetFileStream(_path);
|
||||
if (stream != nullptr)
|
||||
if (_zipPath.empty())
|
||||
{
|
||||
return std::make_unique<ZipStreamWrapper>(std::move(zipArchive), std::move(stream));
|
||||
return std::make_unique<FileStream>(_path, FILE_MODE_OPEN);
|
||||
}
|
||||
|
||||
auto zipArchive = Zip::TryOpen(_zipPath, ZIP_ACCESS::READ);
|
||||
if (zipArchive != nullptr)
|
||||
{
|
||||
auto stream = zipArchive->GetFileStream(_path);
|
||||
if (stream != nullptr)
|
||||
{
|
||||
return std::make_unique<ZipStreamWrapper>(std::move(zipArchive), std::move(stream));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user