mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-30 04:40:53 +00:00
Changed: #1249 Endianness problems while access to disk or memory
This commit is contained in:
parent
0557ec99d5
commit
8e1a1acb5d
3 changed files with 54 additions and 0 deletions
|
@ -1224,6 +1224,11 @@ void CFileContainer::addSearchBigFile (const string &sBigFilename, bool recurse,
|
|||
fclose(Handle);
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef NL_BIG_ENDIAN
|
||||
NLMISC_BSWAP32(nOffsetFromBegining);
|
||||
#endif
|
||||
|
||||
nlfseek64 (Handle, nOffsetFromBegining, SEEK_SET);
|
||||
uint32 nNbFile;
|
||||
if (fread (&nNbFile, sizeof(uint32), 1, Handle) != 1)
|
||||
|
@ -1231,6 +1236,11 @@ void CFileContainer::addSearchBigFile (const string &sBigFilename, bool recurse,
|
|||
fclose(Handle);
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef NL_BIG_ENDIAN
|
||||
NLMISC_BSWAP32(nNbFile);
|
||||
#endif
|
||||
|
||||
for (uint32 i = 0; i < nNbFile; ++i)
|
||||
{
|
||||
// Progress bar
|
||||
|
@ -1259,12 +1269,22 @@ void CFileContainer::addSearchBigFile (const string &sBigFilename, bool recurse,
|
|||
fclose(Handle);
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef NL_BIG_ENDIAN
|
||||
NLMISC_BSWAP32(nFileSize2);
|
||||
#endif
|
||||
|
||||
uint32 nFilePos;
|
||||
if (fread (&nFilePos, sizeof(uint32), 1, Handle) != 1)
|
||||
{
|
||||
fclose(Handle);
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef NL_BIG_ENDIAN
|
||||
NLMISC_BSWAP32(nFilePos);
|
||||
#endif
|
||||
|
||||
string sTmp = toLower(string(FileName));
|
||||
if (sTmp.empty())
|
||||
{
|
||||
|
|
|
@ -154,6 +154,10 @@ struct BNPHeader
|
|||
return false;
|
||||
}
|
||||
|
||||
#ifdef NL_BIG_ENDIAN
|
||||
NLMISC_BSWAP32(nOffsetFromBegining);
|
||||
#endif
|
||||
|
||||
if (nlfseek64 (f, nOffsetFromBegining, SEEK_SET) != 0)
|
||||
{
|
||||
fclose (f);
|
||||
|
@ -167,6 +171,10 @@ struct BNPHeader
|
|||
return false;
|
||||
}
|
||||
|
||||
#ifdef NL_BIG_ENDIAN
|
||||
NLMISC_BSWAP32(nNbFile);
|
||||
#endif
|
||||
|
||||
for (uint32 i = 0; i < nNbFile; ++i)
|
||||
{
|
||||
uint8 nStringSize;
|
||||
|
@ -189,11 +197,21 @@ struct BNPHeader
|
|||
fclose (f);
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef NL_BIG_ENDIAN
|
||||
NLMISC_BSWAP32(tmpBNPFile.Size);
|
||||
#endif
|
||||
|
||||
if (fread (&tmpBNPFile.Pos, sizeof(uint32), 1, f) != 1)
|
||||
{
|
||||
fclose (f);
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef NL_BIG_ENDIAN
|
||||
NLMISC_BSWAP32(tmpBNPFile.Pos);
|
||||
#endif
|
||||
|
||||
Files.push_back (tmpBNPFile);
|
||||
}
|
||||
|
||||
|
|
|
@ -1708,6 +1708,10 @@ bool CPatchManager::readBNPHeader(const string &SourceName, vector<SBNPFile> &Fi
|
|||
return false;
|
||||
}
|
||||
|
||||
#ifdef NL_BIG_ENDIAN
|
||||
NLMISC_BSWAP32(nOffsetFromBegining);
|
||||
#endif
|
||||
|
||||
if (nlfseek64 (f, nOffsetFromBegining, SEEK_SET) != 0)
|
||||
{
|
||||
fclose(f);
|
||||
|
@ -1721,6 +1725,10 @@ bool CPatchManager::readBNPHeader(const string &SourceName, vector<SBNPFile> &Fi
|
|||
return false;
|
||||
}
|
||||
|
||||
#ifdef NL_BIG_ENDIAN
|
||||
NLMISC_BSWAP32(nNbFile);
|
||||
#endif
|
||||
|
||||
for (uint32 i = 0; i < nNbFile; ++i)
|
||||
{
|
||||
uint8 nStringSize;
|
||||
|
@ -1746,12 +1754,20 @@ bool CPatchManager::readBNPHeader(const string &SourceName, vector<SBNPFile> &Fi
|
|||
return false;
|
||||
}
|
||||
|
||||
#ifdef NL_BIG_ENDIAN
|
||||
NLMISC_BSWAP32(tmpBNPFile.Size);
|
||||
#endif
|
||||
|
||||
if (fread (&tmpBNPFile.Pos, sizeof(uint32), 1, f) != 1)
|
||||
{
|
||||
fclose(f);
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef NL_BIG_ENDIAN
|
||||
NLMISC_BSWAP32(tmpBNPFile.Pos);
|
||||
#endif
|
||||
|
||||
Files.push_back (tmpBNPFile);
|
||||
}
|
||||
fclose (f);
|
||||
|
|
Loading…
Reference in a new issue