Changed: Some Big endian swaps (for PowerPC especially)
This commit is contained in:
parent
892c2d9a45
commit
fd4376b1a4
3 changed files with 43 additions and 4 deletions
|
@ -61,6 +61,10 @@ uint8 getType(const std::string &sFileNameDest)
|
|||
return NOT_DEFINED;
|
||||
}
|
||||
|
||||
#ifdef NL_BIG_ENDIAN
|
||||
NLMISC_BSWAP32(dds);
|
||||
#endif
|
||||
|
||||
if (fread(&h,sizeof(CS3TCCompressor::DDS_HEADER),1,f) != 1)
|
||||
{
|
||||
fclose(f);
|
||||
|
|
|
@ -69,11 +69,20 @@ int main(int argc, char* argv[])
|
|||
if (fread (&size, sizeof(uint32), 1, file) != 1)
|
||||
break;
|
||||
|
||||
#ifdef NL_BIG_ENDIAN
|
||||
NLMISC_BSWAP32(size);
|
||||
#endif
|
||||
|
||||
while (1)
|
||||
{
|
||||
uint32 start;
|
||||
if (fread (&start, sizeof(uint32), 1, file) != 1)
|
||||
break;
|
||||
|
||||
#ifdef NL_BIG_ENDIAN
|
||||
NLMISC_BSWAP32(start);
|
||||
#endif
|
||||
|
||||
string category;
|
||||
if (!readString (category, file))
|
||||
break;
|
||||
|
|
|
@ -94,7 +94,15 @@ struct BNPHeader
|
|||
if (f == NULL) return false;
|
||||
|
||||
uint32 nNbFile = (uint32)Files.size();
|
||||
if (fwrite (&nNbFile, sizeof(uint32), 1, f) != 1)
|
||||
|
||||
// value to be serialized
|
||||
uint32 nNbFile2 = nNbFile;
|
||||
|
||||
#ifdef NL_BIG_ENDIAN
|
||||
NLMISC_BSWAP32(nNbFile2);
|
||||
#endif
|
||||
|
||||
if (fwrite (&nNbFile2, sizeof(uint32), 1, f) != 1)
|
||||
{
|
||||
fclose(f);
|
||||
return false;
|
||||
|
@ -115,20 +123,38 @@ struct BNPHeader
|
|||
return false;
|
||||
}
|
||||
|
||||
if (fwrite (&Files[i].Size, sizeof(uint32), 1, f) != 1)
|
||||
uint32 nFileSize = Files[i].Size;
|
||||
|
||||
#ifdef NL_BIG_ENDIAN
|
||||
NLMISC_BSWAP32(nFileSize);
|
||||
#endif
|
||||
|
||||
if (fwrite (&nFileSize, sizeof(uint32), 1, f) != 1)
|
||||
{
|
||||
fclose(f);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fwrite (&Files[i].Pos, sizeof(uint32), 1, f) != 1)
|
||||
uint32 nFilePos = Files[i].Pos;
|
||||
|
||||
#ifdef NL_BIG_ENDIAN
|
||||
NLMISC_BSWAP32(nFilePos);
|
||||
#endif
|
||||
|
||||
if (fwrite (&nFilePos, sizeof(uint32), 1, f) != 1)
|
||||
{
|
||||
fclose(f);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (fwrite (&OffsetFromBeginning, sizeof(uint32), 1, f) != 1)
|
||||
uint32 nOffsetFromBeginning = OffsetFromBeginning;
|
||||
|
||||
#ifdef NL_BIG_ENDIAN
|
||||
NLMISC_BSWAP32(nOffsetFromBeginning);
|
||||
#endif
|
||||
|
||||
if (fwrite (&nOffsetFromBeginning, sizeof(uint32), 1, f) != 1)
|
||||
{
|
||||
fclose(f);
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue