Skip to content

Commit

Permalink
Include the stream::tell() method call in the thread lock guard to fi…
Browse files Browse the repository at this point in the history
…x the intermittent parsing errors.

Fix wrong file name.
  • Loading branch information
codereader committed Aug 31, 2017
1 parent 4b6e3e2 commit d6d28b0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
File renamed without changes.
22 changes: 10 additions & 12 deletions plugins/archivezip/ZipArchive.cpp
Expand Up @@ -12,7 +12,7 @@
#include "ZipStreamUtils.h"
#include "DeflatedArchiveFile.h"
#include "DeflatedArchiveTextFile.h"
#include "StoreArchiveFile.h"
#include "StoredArchiveFile.h"
#include "StoredArchiveTextFile.h"

namespace archive
Expand Down Expand Up @@ -104,20 +104,18 @@ ArchiveTextFilePtr ZipArchive::openTextFile(const std::string& name)
{
const std::shared_ptr<ZipRecord>& file = i->second.getRecord();

{
// Guard against concurrent access
std::lock_guard<std::mutex> lock(_streamLock);
// Guard against concurrent access
std::lock_guard<std::mutex> lock(_streamLock);

_istream.seek(file->position);
_istream.seek(file->position);

ZipFileHeader header;
stream::readZipFileHeader(_istream, header);
ZipFileHeader header;
stream::readZipFileHeader(_istream, header);

if (header.magic != ZIP_MAGIC_FILE_HEADER)
{
rError() << "Error reading zip file " << _fullPath << std::endl;
return ArchiveTextFilePtr();
}
if (header.magic != ZIP_MAGIC_FILE_HEADER)
{
rError() << "Error reading zip file " << _fullPath << std::endl;
return ArchiveTextFilePtr();
}

std::string modDir = game::current::getModPath(_containingFolder);
Expand Down
2 changes: 1 addition & 1 deletion tools/msvc/archivezip.vcxproj
Expand Up @@ -311,7 +311,7 @@
<ClInclude Include="..\..\plugins\archivezip\DeflatedArchiveTextFile.h" />
<ClInclude Include="..\..\plugins\archivezip\DeflatedInputStream.h" />
<ClInclude Include="..\..\plugins\archivezip\GenericFileSystem.h" />
<ClInclude Include="..\..\plugins\archivezip\StoreArchiveFile.h" />
<ClInclude Include="..\..\plugins\archivezip\StoredArchiveFile.h" />
<ClInclude Include="..\..\plugins\archivezip\StoredArchiveTextFile.h" />
<ClInclude Include="..\..\plugins\archivezip\ZipArchive.h" />
<ClInclude Include="..\..\plugins\archivezip\ZipStreamUtils.h" />
Expand Down
4 changes: 2 additions & 2 deletions tools/msvc/archivezip.vcxproj.filters
Expand Up @@ -25,10 +25,10 @@
<ClInclude Include="..\..\plugins\archivezip\DeflatedInputStream.h">
<Filter>src</Filter>
</ClInclude>
<ClInclude Include="..\..\plugins\archivezip\StoreArchiveFile.h">
<ClInclude Include="..\..\plugins\archivezip\StoredArchiveTextFile.h">
<Filter>src</Filter>
</ClInclude>
<ClInclude Include="..\..\plugins\archivezip\StoredArchiveTextFile.h">
<ClInclude Include="..\..\plugins\archivezip\StoredArchiveFile.h">
<Filter>src</Filter>
</ClInclude>
</ItemGroup>
Expand Down

0 comments on commit d6d28b0

Please sign in to comment.