mirror of https://github.com/PCSX2/pcsx2.git
pcsx2/: remove ^M eol on 3 files
This commit is contained in:
parent
50868f14f6
commit
e7d0a0345e
|
@ -13,175 +13,175 @@
|
||||||
* If not, see <http://www.gnu.org/licenses/>.
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
# include <Windows.h>
|
# include <Windows.h>
|
||||||
# undef Yield
|
# undef Yield
|
||||||
#else
|
#else
|
||||||
# include <libaio.h>
|
# include <libaio.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class AsyncFileReader
|
class AsyncFileReader
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
AsyncFileReader(void) {m_dataoffset=0;}
|
AsyncFileReader(void) {m_dataoffset=0;}
|
||||||
|
|
||||||
wxString m_filename;
|
wxString m_filename;
|
||||||
|
|
||||||
uint m_dataoffset;
|
uint m_dataoffset;
|
||||||
uint m_blocksize;
|
uint m_blocksize;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~AsyncFileReader(void) {};
|
virtual ~AsyncFileReader(void) {};
|
||||||
|
|
||||||
virtual bool Open(const wxString& fileName)=0;
|
virtual bool Open(const wxString& fileName)=0;
|
||||||
|
|
||||||
virtual int ReadSync(void* pBuffer, uint sector, uint count)=0;
|
virtual int ReadSync(void* pBuffer, uint sector, uint count)=0;
|
||||||
|
|
||||||
virtual void BeginRead(void* pBuffer, uint sector, uint count)=0;
|
virtual void BeginRead(void* pBuffer, uint sector, uint count)=0;
|
||||||
virtual int FinishRead(void)=0;
|
virtual int FinishRead(void)=0;
|
||||||
virtual void CancelRead(void)=0;
|
virtual void CancelRead(void)=0;
|
||||||
|
|
||||||
virtual void Close(void)=0;
|
virtual void Close(void)=0;
|
||||||
|
|
||||||
virtual uint GetBlockCount(void) const=0;
|
virtual uint GetBlockCount(void) const=0;
|
||||||
|
|
||||||
virtual void SetBlockSize(uint bytes) {}
|
virtual void SetBlockSize(uint bytes) {}
|
||||||
virtual void SetDataOffset(uint bytes) {}
|
virtual void SetDataOffset(uint bytes) {}
|
||||||
|
|
||||||
uint GetBlockSize() const { return m_blocksize; }
|
uint GetBlockSize() const { return m_blocksize; }
|
||||||
|
|
||||||
const wxString& GetFilename() const
|
const wxString& GetFilename() const
|
||||||
{
|
{
|
||||||
return m_filename;
|
return m_filename;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class FlatFileReader : public AsyncFileReader
|
class FlatFileReader : public AsyncFileReader
|
||||||
{
|
{
|
||||||
DeclareNoncopyableObject( FlatFileReader );
|
DeclareNoncopyableObject( FlatFileReader );
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
HANDLE hOverlappedFile;
|
HANDLE hOverlappedFile;
|
||||||
|
|
||||||
OVERLAPPED asyncOperationContext;
|
OVERLAPPED asyncOperationContext;
|
||||||
|
|
||||||
HANDLE hEvent;
|
HANDLE hEvent;
|
||||||
|
|
||||||
bool asyncInProgress;
|
bool asyncInProgress;
|
||||||
#else
|
#else
|
||||||
int m_fd; // FIXME don't know if overlap as an equivalent on linux
|
int m_fd; // FIXME don't know if overlap as an equivalent on linux
|
||||||
io_context_t m_aio_context;
|
io_context_t m_aio_context;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FlatFileReader(void);
|
FlatFileReader(void);
|
||||||
virtual ~FlatFileReader(void);
|
virtual ~FlatFileReader(void);
|
||||||
|
|
||||||
virtual bool Open(const wxString& fileName);
|
virtual bool Open(const wxString& fileName);
|
||||||
|
|
||||||
virtual int ReadSync(void* pBuffer, uint sector, uint count);
|
virtual int ReadSync(void* pBuffer, uint sector, uint count);
|
||||||
|
|
||||||
virtual void BeginRead(void* pBuffer, uint sector, uint count);
|
virtual void BeginRead(void* pBuffer, uint sector, uint count);
|
||||||
virtual int FinishRead(void);
|
virtual int FinishRead(void);
|
||||||
virtual void CancelRead(void);
|
virtual void CancelRead(void);
|
||||||
|
|
||||||
virtual void Close(void);
|
virtual void Close(void);
|
||||||
|
|
||||||
virtual uint GetBlockCount(void) const;
|
virtual uint GetBlockCount(void) const;
|
||||||
|
|
||||||
virtual void SetBlockSize(uint bytes) { m_blocksize = bytes; }
|
virtual void SetBlockSize(uint bytes) { m_blocksize = bytes; }
|
||||||
virtual void SetDataOffset(uint bytes) { m_dataoffset = bytes; }
|
virtual void SetDataOffset(uint bytes) { m_dataoffset = bytes; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Factory - creates an AsyncFileReader derived instance which can read a compressed file
|
// Factory - creates an AsyncFileReader derived instance which can read a compressed file
|
||||||
class CompressedFileReader {
|
class CompressedFileReader {
|
||||||
public:
|
public:
|
||||||
// Checks if any of the available compressed file handlers can open this
|
// Checks if any of the available compressed file handlers can open this
|
||||||
static bool DetectCompressed(AsyncFileReader* pReader);
|
static bool DetectCompressed(AsyncFileReader* pReader);
|
||||||
|
|
||||||
// fileName is only used to choose the compressed reader.
|
// fileName is only used to choose the compressed reader.
|
||||||
// If no matching handler is found then an arbitrary handlers will be returned.
|
// If no matching handler is found then an arbitrary handlers will be returned.
|
||||||
// The returned instance still needs ->Open(filename) before usage.
|
// The returned instance still needs ->Open(filename) before usage.
|
||||||
// Open(filename) may still fail.
|
// Open(filename) may still fail.
|
||||||
static AsyncFileReader* GetNewReader(const wxString& fileName);
|
static AsyncFileReader* GetNewReader(const wxString& fileName);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual ~CompressedFileReader() = 0;
|
virtual ~CompressedFileReader() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MultipartFileReader : public AsyncFileReader
|
class MultipartFileReader : public AsyncFileReader
|
||||||
{
|
{
|
||||||
DeclareNoncopyableObject( MultipartFileReader );
|
DeclareNoncopyableObject( MultipartFileReader );
|
||||||
|
|
||||||
static const int MaxParts = 8;
|
static const int MaxParts = 8;
|
||||||
|
|
||||||
struct Part {
|
struct Part {
|
||||||
uint start;
|
uint start;
|
||||||
uint end; // exclusive
|
uint end; // exclusive
|
||||||
bool isReading;
|
bool isReading;
|
||||||
AsyncFileReader* reader;
|
AsyncFileReader* reader;
|
||||||
} m_parts[MaxParts];
|
} m_parts[MaxParts];
|
||||||
uint m_numparts;
|
uint m_numparts;
|
||||||
|
|
||||||
uint GetFirstPart(uint lsn);
|
uint GetFirstPart(uint lsn);
|
||||||
void FindParts();
|
void FindParts();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MultipartFileReader(AsyncFileReader* firstPart);
|
MultipartFileReader(AsyncFileReader* firstPart);
|
||||||
virtual ~MultipartFileReader(void);
|
virtual ~MultipartFileReader(void);
|
||||||
|
|
||||||
virtual bool Open(const wxString& fileName);
|
virtual bool Open(const wxString& fileName);
|
||||||
|
|
||||||
virtual int ReadSync(void* pBuffer, uint sector, uint count);
|
virtual int ReadSync(void* pBuffer, uint sector, uint count);
|
||||||
|
|
||||||
virtual void BeginRead(void* pBuffer, uint sector, uint count);
|
virtual void BeginRead(void* pBuffer, uint sector, uint count);
|
||||||
virtual int FinishRead(void);
|
virtual int FinishRead(void);
|
||||||
virtual void CancelRead(void);
|
virtual void CancelRead(void);
|
||||||
|
|
||||||
virtual void Close(void);
|
virtual void Close(void);
|
||||||
|
|
||||||
virtual uint GetBlockCount(void) const;
|
virtual uint GetBlockCount(void) const;
|
||||||
|
|
||||||
virtual void SetBlockSize(uint bytes);
|
virtual void SetBlockSize(uint bytes);
|
||||||
|
|
||||||
static AsyncFileReader* DetectMultipart(AsyncFileReader* reader);
|
static AsyncFileReader* DetectMultipart(AsyncFileReader* reader);
|
||||||
};
|
};
|
||||||
|
|
||||||
class BlockdumpFileReader : public AsyncFileReader
|
class BlockdumpFileReader : public AsyncFileReader
|
||||||
{
|
{
|
||||||
DeclareNoncopyableObject( BlockdumpFileReader );
|
DeclareNoncopyableObject( BlockdumpFileReader );
|
||||||
|
|
||||||
wxFileInputStream* m_file;
|
wxFileInputStream* m_file;
|
||||||
|
|
||||||
// total number of blocks in the ISO image (including all parts)
|
// total number of blocks in the ISO image (including all parts)
|
||||||
u32 m_blocks;
|
u32 m_blocks;
|
||||||
s32 m_blockofs;
|
s32 m_blockofs;
|
||||||
|
|
||||||
// index table
|
// index table
|
||||||
ScopedArray<u32> m_dtable;
|
ScopedArray<u32> m_dtable;
|
||||||
int m_dtablesize;
|
int m_dtablesize;
|
||||||
|
|
||||||
int m_lresult;
|
int m_lresult;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BlockdumpFileReader(void);
|
BlockdumpFileReader(void);
|
||||||
virtual ~BlockdumpFileReader(void);
|
virtual ~BlockdumpFileReader(void);
|
||||||
|
|
||||||
virtual bool Open(const wxString& fileName);
|
virtual bool Open(const wxString& fileName);
|
||||||
|
|
||||||
virtual int ReadSync(void* pBuffer, uint sector, uint count);
|
virtual int ReadSync(void* pBuffer, uint sector, uint count);
|
||||||
|
|
||||||
virtual void BeginRead(void* pBuffer, uint sector, uint count);
|
virtual void BeginRead(void* pBuffer, uint sector, uint count);
|
||||||
virtual int FinishRead(void);
|
virtual int FinishRead(void);
|
||||||
virtual void CancelRead(void);
|
virtual void CancelRead(void);
|
||||||
|
|
||||||
virtual void Close(void);
|
virtual void Close(void);
|
||||||
|
|
||||||
virtual uint GetBlockCount(void) const;
|
virtual uint GetBlockCount(void) const;
|
||||||
|
|
||||||
static bool DetectBlockdump(AsyncFileReader* reader);
|
static bool DetectBlockdump(AsyncFileReader* reader);
|
||||||
|
|
||||||
int GetBlockOffset() { return m_blockofs; }
|
int GetBlockOffset() { return m_blockofs; }
|
||||||
};
|
};
|
||||||
|
|
|
@ -13,172 +13,172 @@
|
||||||
* If not, see <http://www.gnu.org/licenses/>.
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "PrecompiledHeader.h"
|
#include "PrecompiledHeader.h"
|
||||||
#include "AsyncFileReader.h"
|
#include "AsyncFileReader.h"
|
||||||
#include "IopCommon.h"
|
#include "IopCommon.h"
|
||||||
#include "IsoFileFormats.h"
|
#include "IsoFileFormats.h"
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
enum isoFlags
|
enum isoFlags
|
||||||
{
|
{
|
||||||
ISOFLAGS_BLOCKDUMP_V2 = 0x0004,
|
ISOFLAGS_BLOCKDUMP_V2 = 0x0004,
|
||||||
ISOFLAGS_BLOCKDUMP_V3 = 0x0020
|
ISOFLAGS_BLOCKDUMP_V3 = 0x0020
|
||||||
};
|
};
|
||||||
|
|
||||||
static const uint BlockDumpHeaderSize = 16;
|
static const uint BlockDumpHeaderSize = 16;
|
||||||
|
|
||||||
bool BlockdumpFileReader::DetectBlockdump(AsyncFileReader* reader)
|
bool BlockdumpFileReader::DetectBlockdump(AsyncFileReader* reader)
|
||||||
{
|
{
|
||||||
uint oldbs = reader->GetBlockSize();
|
uint oldbs = reader->GetBlockSize();
|
||||||
|
|
||||||
reader->SetBlockSize(1);
|
reader->SetBlockSize(1);
|
||||||
|
|
||||||
char buf[4];
|
char buf[4];
|
||||||
reader->ReadSync(buf, 0, 4);
|
reader->ReadSync(buf, 0, 4);
|
||||||
|
|
||||||
bool isbd = (strncmp(buf, "BDV2", 4) == 0);
|
bool isbd = (strncmp(buf, "BDV2", 4) == 0);
|
||||||
|
|
||||||
if(!isbd)
|
if(!isbd)
|
||||||
reader->SetBlockSize(oldbs);
|
reader->SetBlockSize(oldbs);
|
||||||
|
|
||||||
return isbd;
|
return isbd;
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockdumpFileReader::BlockdumpFileReader(void)
|
BlockdumpFileReader::BlockdumpFileReader(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockdumpFileReader::~BlockdumpFileReader(void)
|
BlockdumpFileReader::~BlockdumpFileReader(void)
|
||||||
{
|
{
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BlockdumpFileReader::Open(const wxString& fileName)
|
bool BlockdumpFileReader::Open(const wxString& fileName)
|
||||||
{
|
{
|
||||||
char buf[32];
|
char buf[32];
|
||||||
|
|
||||||
m_filename = fileName;
|
m_filename = fileName;
|
||||||
|
|
||||||
m_file = new wxFileInputStream( m_filename );
|
m_file = new wxFileInputStream( m_filename );
|
||||||
|
|
||||||
m_file->SeekI(0);
|
m_file->SeekI(0);
|
||||||
m_file->Read(buf, 4);
|
m_file->Read(buf, 4);
|
||||||
|
|
||||||
if (strncmp(buf, "BDV2", 4) != 0)
|
if (strncmp(buf, "BDV2", 4) != 0)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//m_flags = ISOFLAGS_BLOCKDUMP_V2;
|
//m_flags = ISOFLAGS_BLOCKDUMP_V2;
|
||||||
m_file->Read(&m_blocksize, sizeof(m_blocksize));
|
m_file->Read(&m_blocksize, sizeof(m_blocksize));
|
||||||
m_file->Read(&m_blocks, sizeof(m_blocks));
|
m_file->Read(&m_blocks, sizeof(m_blocks));
|
||||||
m_file->Read(&m_blockofs, sizeof(m_blockofs));
|
m_file->Read(&m_blockofs, sizeof(m_blockofs));
|
||||||
|
|
||||||
wxFileOffset flen = m_file->GetLength();
|
wxFileOffset flen = m_file->GetLength();
|
||||||
static const wxFileOffset datalen = flen - BlockDumpHeaderSize;
|
static const wxFileOffset datalen = flen - BlockDumpHeaderSize;
|
||||||
|
|
||||||
pxAssert( (datalen % (m_blocksize + 4)) == 0);
|
pxAssert( (datalen % (m_blocksize + 4)) == 0);
|
||||||
|
|
||||||
m_dtablesize = datalen / (m_blocksize + 4);
|
m_dtablesize = datalen / (m_blocksize + 4);
|
||||||
m_dtable = new u32[m_dtablesize];
|
m_dtable = new u32[m_dtablesize];
|
||||||
|
|
||||||
m_file->SeekI(BlockDumpHeaderSize);
|
m_file->SeekI(BlockDumpHeaderSize);
|
||||||
|
|
||||||
ScopedPtr<u8> buffer;
|
ScopedPtr<u8> buffer;
|
||||||
u32 bs = 1024*1024;
|
u32 bs = 1024*1024;
|
||||||
u32 off = 0;
|
u32 off = 0;
|
||||||
u32 has = 0;
|
u32 has = 0;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
buffer = new u8[bs];
|
buffer = new u8[bs];
|
||||||
do {
|
do {
|
||||||
m_file->Read(buffer, bs);
|
m_file->Read(buffer, bs);
|
||||||
has = m_file->LastRead();
|
has = m_file->LastRead();
|
||||||
|
|
||||||
while (i < m_dtablesize && off < has)
|
while (i < m_dtablesize && off < has)
|
||||||
{
|
{
|
||||||
m_dtable[i++] = *(u32*)(buffer + off);
|
m_dtable[i++] = *(u32*)(buffer + off);
|
||||||
off += 4;
|
off += 4;
|
||||||
off += m_blocksize;
|
off += m_blocksize;
|
||||||
}
|
}
|
||||||
|
|
||||||
off -= has;
|
off -= has;
|
||||||
|
|
||||||
} while(has == bs);
|
} while(has == bs);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int BlockdumpFileReader::ReadSync(void* pBuffer, uint lsn, uint count)
|
int BlockdumpFileReader::ReadSync(void* pBuffer, uint lsn, uint count)
|
||||||
{
|
{
|
||||||
u8* dst = (u8*)pBuffer;
|
u8* dst = (u8*)pBuffer;
|
||||||
// Console.WriteLn("_isoReadBlockD %u, blocksize=%u, blockofs=%u\n", lsn, iso->blocksize, iso->blockofs);
|
// Console.WriteLn("_isoReadBlockD %u, blocksize=%u, blockofs=%u\n", lsn, iso->blocksize, iso->blockofs);
|
||||||
|
|
||||||
while(count > 0)
|
while(count > 0)
|
||||||
{
|
{
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
for (int i = 0; i < m_dtablesize; ++i)
|
for (int i = 0; i < m_dtablesize; ++i)
|
||||||
{
|
{
|
||||||
if (m_dtable[i] != lsn)
|
if (m_dtable[i] != lsn)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// We store the LSN (u32) along with each block inside of blockdumps, so the
|
// We store the LSN (u32) along with each block inside of blockdumps, so the
|
||||||
// seek position ends up being based on (m_blocksize + 4) instead of just m_blocksize.
|
// seek position ends up being based on (m_blocksize + 4) instead of just m_blocksize.
|
||||||
|
|
||||||
#ifdef PCSX2_DEBUG
|
#ifdef PCSX2_DEBUG
|
||||||
u32 check_lsn;
|
u32 check_lsn;
|
||||||
m_file->SeekI( BlockDumpHeaderSize + (i * (m_blocksize + 4)) );
|
m_file->SeekI( BlockDumpHeaderSize + (i * (m_blocksize + 4)) );
|
||||||
m_file->Read( &check_lsn, sizeof(check_lsn) );
|
m_file->Read( &check_lsn, sizeof(check_lsn) );
|
||||||
pxAssert( check_lsn == lsn );
|
pxAssert( check_lsn == lsn );
|
||||||
#else
|
#else
|
||||||
m_file->SeekI( BlockDumpHeaderSize + (i * (m_blocksize + 4)) + 4 );
|
m_file->SeekI( BlockDumpHeaderSize + (i * (m_blocksize + 4)) + 4 );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_file->Read( dst, m_blocksize );
|
m_file->Read( dst, m_blocksize );
|
||||||
|
|
||||||
ok = true;
|
ok = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!ok)
|
if(!ok)
|
||||||
{
|
{
|
||||||
Console.WriteLn("Block %u not found in dump", lsn);
|
Console.WriteLn("Block %u not found in dump", lsn);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
count--;
|
count--;
|
||||||
lsn++;
|
lsn++;
|
||||||
dst += m_blocksize;
|
dst += m_blocksize;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlockdumpFileReader::BeginRead(void* pBuffer, uint sector, uint count)
|
void BlockdumpFileReader::BeginRead(void* pBuffer, uint sector, uint count)
|
||||||
{
|
{
|
||||||
m_lresult = ReadSync(pBuffer, sector, count);
|
m_lresult = ReadSync(pBuffer, sector, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
int BlockdumpFileReader::FinishRead(void)
|
int BlockdumpFileReader::FinishRead(void)
|
||||||
{
|
{
|
||||||
return m_lresult;
|
return m_lresult;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlockdumpFileReader::CancelRead(void)
|
void BlockdumpFileReader::CancelRead(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlockdumpFileReader::Close(void)
|
void BlockdumpFileReader::Close(void)
|
||||||
{
|
{
|
||||||
if(m_file)
|
if(m_file)
|
||||||
{
|
{
|
||||||
delete m_file;
|
delete m_file;
|
||||||
m_file = NULL;
|
m_file = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint BlockdumpFileReader::GetBlockCount(void) const
|
uint BlockdumpFileReader::GetBlockCount(void) const
|
||||||
{
|
{
|
||||||
return m_blocks;
|
return m_blocks;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue