mirror of
https://github.com/libretro/ppsspp.git
synced 2025-01-19 07:04:45 +00:00
Specify file data layout endianness.
This commit is contained in:
parent
bfb05440e2
commit
79c4104456
@ -70,23 +70,23 @@ bool FileBlockDevice::ReadBlock(int blockNumber, u8 *outPtr)
|
||||
// compressed ISO(9660) header format
|
||||
typedef struct ciso_header
|
||||
{
|
||||
unsigned char magic[4]; // +00 : 'C','I','S','O'
|
||||
u32 header_size; // +04 : header size (==0x18)
|
||||
u64 total_bytes; // +08 : number of original data size
|
||||
u32 block_size; // +10 : number of compressed block size
|
||||
unsigned char ver; // +14 : version 01
|
||||
unsigned char align; // +15 : align of index value
|
||||
unsigned char rsv_06[2]; // +16 : reserved
|
||||
unsigned char magic[4]; // +00 : 'C','I','S','O'
|
||||
u32_le header_size; // +04 : header size (==0x18)
|
||||
u64_le total_bytes; // +08 : number of original data size
|
||||
u32_le block_size; // +10 : number of compressed block size
|
||||
unsigned char ver; // +14 : version 01
|
||||
unsigned char align; // +15 : align of index value
|
||||
unsigned char rsv_06[2]; // +16 : reserved
|
||||
#if 0
|
||||
// INDEX BLOCK
|
||||
unsigned int index[0]; // +18 : block[0] index
|
||||
unsigned int index[1]; // +1C : block[1] index
|
||||
unsigned int index[0]; // +18 : block[0] index
|
||||
unsigned int index[1]; // +1C : block[1] index
|
||||
:
|
||||
:
|
||||
unsigned int index[last]; // +?? : block[last]
|
||||
unsigned int index[last+1]; // +?? : end of last data point
|
||||
unsigned int index[last]; // +?? : block[last]
|
||||
unsigned int index[last+1]; // +?? : end of last data point
|
||||
// DATA BLOCK
|
||||
unsigned char data[]; // +?? : compressed or plain sector data
|
||||
unsigned char data[]; // +?? : compressed or plain sector data
|
||||
#endif
|
||||
} CISO_H;
|
||||
|
||||
@ -128,9 +128,18 @@ CISOFileBlockDevice::CISOFileBlockDevice(FILE *file)
|
||||
|
||||
u32 indexSize = numBlocks + 1;
|
||||
|
||||
#if COMMON_LITTLE_ENDIAN
|
||||
index = new u32[indexSize];
|
||||
if(fread(index, sizeof(u32), indexSize, f) != indexSize)
|
||||
if (fread(index, sizeof(u32), indexSize, f) != indexSize)
|
||||
memset(index, 0, indexSize * sizeof(u32));
|
||||
#else
|
||||
index = new u32[indexSize];
|
||||
u32_le *indexTemp = new u32_le[indexSize];
|
||||
if (fread(indexTemp, sizeof(u32), indexSize, f) != indexSize)
|
||||
memset(indexTemp, 0, indexSize * sizeof(u32_le));
|
||||
for (u32 i = 0; i < indexSize; i++)
|
||||
index[i] = indexTemp[i];
|
||||
#endif
|
||||
}
|
||||
|
||||
CISOFileBlockDevice::~CISOFileBlockDevice()
|
||||
|
@ -81,6 +81,34 @@ struct DirectoryEntry
|
||||
u16 volSeqNumberBE;
|
||||
u8 identifierLength; //identifier comes right after
|
||||
u8 firstIdChar;
|
||||
|
||||
#if COMMON_LITTLE_ENDIAN
|
||||
u32 firstDataSector() const
|
||||
{
|
||||
return firstDataSectorLE;
|
||||
}
|
||||
u32 dataLength() const
|
||||
{
|
||||
return dataLengthLE;
|
||||
}
|
||||
u32 volSeqNumber() const
|
||||
{
|
||||
return volSeqNumberLE;
|
||||
}
|
||||
#else
|
||||
u32 firstDataSector() const
|
||||
{
|
||||
return firstDataSectorBE;
|
||||
}
|
||||
u32 dataLength() const
|
||||
{
|
||||
return dataLengthBE;
|
||||
}
|
||||
u32 volSeqNumber() const
|
||||
{
|
||||
return volSeqNumberBE;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
struct DirectorySector
|
||||
{
|
||||
@ -175,8 +203,8 @@ ISOFileSystem::ISOFileSystem(IHandleAllocator *_hAlloc, BlockDevice *_blockDevic
|
||||
treeroot->flags = 0;
|
||||
treeroot->parent = NULL;
|
||||
|
||||
u32 rootSector = desc.root.firstDataSectorLE;
|
||||
u32 rootSize = desc.root.dataLengthLE;
|
||||
u32 rootSector = desc.root.firstDataSector();
|
||||
u32 rootSize = desc.root.dataLength();
|
||||
|
||||
ReadDirectory(rootSector, rootSize, treeroot, 0);
|
||||
}
|
||||
@ -232,8 +260,8 @@ void ISOFileSystem::ReadDirectory(u32 startsector, u32 dirsize, TreeEntry *root,
|
||||
relative = false;
|
||||
}
|
||||
|
||||
e->size = dir.dataLengthLE;
|
||||
e->startingPosition = dir.firstDataSectorLE * 2048;
|
||||
e->size = dir.dataLength();
|
||||
e->startingPosition = dir.firstDataSector() * 2048;
|
||||
e->isDirectory = !isFile;
|
||||
e->flags = dir.flags;
|
||||
e->parent = root;
|
||||
@ -243,7 +271,7 @@ void ISOFileSystem::ReadDirectory(u32 startsector, u32 dirsize, TreeEntry *root,
|
||||
|
||||
if (e->isDirectory && !relative)
|
||||
{
|
||||
if (dir.firstDataSectorLE == startsector)
|
||||
if (dir.firstDataSector() == startsector)
|
||||
{
|
||||
ERROR_LOG(FILESYS, "WARNING: Appear to have a recursive file system, breaking recursion");
|
||||
}
|
||||
@ -254,7 +282,7 @@ void ISOFileSystem::ReadDirectory(u32 startsector, u32 dirsize, TreeEntry *root,
|
||||
doRecurse = level < restrictTree.size() && restrictTree[level] == e->name;
|
||||
|
||||
if (doRecurse)
|
||||
ReadDirectory(dir.firstDataSectorLE, dir.dataLengthLE, e, level + 1);
|
||||
ReadDirectory(dir.firstDataSector(), dir.dataLength(), e, level + 1);
|
||||
else
|
||||
continue;
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ EmuFileType Identify_File(std::string &filename)
|
||||
}
|
||||
|
||||
|
||||
u32 id;
|
||||
u32_le id;
|
||||
|
||||
size_t readSize = fread(&id, 4, 1, f);
|
||||
if (readSize != 1) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user