diff --git a/plugins/cdvdGigaherz/src/CDVD.cpp b/plugins/cdvdGigaherz/src/CDVD.cpp index 57d9d9c140..8aadec64a1 100644 --- a/plugins/cdvdGigaherz/src/CDVD.cpp +++ b/plugins/cdvdGigaherz/src/CDVD.cpp @@ -164,7 +164,7 @@ s32 CALLBACK CDVDopen(const char* pTitleFilename) printf(" * CDVD: Opening image '%s'...\n",source_file); //open device file - src=new FileSrc(source_file); + src= TryLoaders(source_file); } else { diff --git a/plugins/cdvdGigaherz/src/CDVD.h b/plugins/cdvdGigaherz/src/CDVD.h index 2a78dc93bd..bb3f0890f0 100644 --- a/plugins/cdvdGigaherz/src/CDVD.h +++ b/plugins/cdvdGigaherz/src/CDVD.h @@ -43,7 +43,6 @@ typedef struct _toc_data extern toc_data cdtoc; - class Source //abstract class as base for source modules { public: @@ -117,56 +116,10 @@ public: virtual s32 DiscChanged(); }; -class FileSrc: public Source -{ -private: - HANDLE fileSource; - - bool OpenOK; - - s32 sector_count; - - char sectorbuffer[32*2048]; - - char fName[256]; - - DWORD sessID; - - bool tocCached; - char tocCacheData[2048]; - - bool mediaTypeCached; - int mediaType; - - bool discSizeCached; - s32 discSize; - - bool layerBreakCached; - s32 layerBreak; - -public: - FileSrc(const char* fileName); - - //virtual destructor - virtual ~FileSrc(); - - //virtual members - virtual s32 GetSectorCount(); - virtual s32 ReadTOC(char *toc,int size); - virtual s32 ReadSectors2048(u32 sector, u32 count, char *buffer); - virtual s32 ReadSectors2352(u32 sector, u32 count, char *buffer); - virtual s32 GetLayerBreakAddress(); - - virtual s32 GetMediaType(); - - virtual s32 IsOK(); - virtual s32 Reopen(); - - virtual s32 DiscChanged(); -}; - extern Source *src; +Source* TryLoaders(const char* fileName); + int FindDiskType(); void configure(); diff --git a/plugins/cdvdGigaherz/src/ReaderModules.cpp b/plugins/cdvdGigaherz/src/ReaderModules.cpp new file mode 100644 index 0000000000..3d69c7ec08 --- /dev/null +++ b/plugins/cdvdGigaherz/src/ReaderModules.cpp @@ -0,0 +1,12 @@ +#include "CDVD.h" +#include "ReaderModules.h" + +Source* TryLoaders(const char* fileName) +{ + Source *src=NULL; + if((src=PlainIso::TryLoad(fileName))!=NULL) return src; + //if((src=CueSheet::TryLoad(fileName))!=NULL) return src; + //if((src=CloneCD::TryLoad(fileName))!=NULL) return src; + //error + return NULL; +} \ No newline at end of file diff --git a/plugins/cdvdGigaherz/src/ReaderModules.h b/plugins/cdvdGigaherz/src/ReaderModules.h new file mode 100644 index 0000000000..bc12500ef9 --- /dev/null +++ b/plugins/cdvdGigaherz/src/ReaderModules.h @@ -0,0 +1,73 @@ +#pragma once + +class Reader: public Source //abstract class as base for Reader modules +{ +public: + //virtual destructor + virtual ~Reader() {} + + //virtual members + virtual s32 GetSectorCount()=0; + virtual s32 ReadTOC(char *toc,int size)=0; + virtual s32 ReadSectors2048(u32 sector, u32 count, char *buffer)=0; + virtual s32 ReadSectors2352(u32 sector, u32 count, char *buffer)=0; + virtual s32 GetLayerBreakAddress()=0; + + virtual s32 GetMediaType()=0; + + virtual s32 IsOK()=0; + virtual s32 Reopen()=0; + + virtual s32 DiscChanged()=0; + + //added members + static Reader* TryLoad(const char* fileName); +}; + +class PlainIso: public Reader +{ + HANDLE fileSource; + + bool OpenOK; + + s32 sector_count; + + char sectorbuffer[32*2048]; + + char fName[256]; + + DWORD sessID; + + bool tocCached; + char tocCacheData[2048]; + + bool mediaTypeCached; + int mediaType; + + bool discSizeCached; + s32 discSize; + + bool layerBreakCached; + s32 layerBreak; + +public: + + PlainIso(const char* fileName); + virtual ~PlainIso(); + + //virtual members + virtual s32 GetSectorCount(); + virtual s32 ReadTOC(char *toc,int size); + virtual s32 ReadSectors2048(u32 sector, u32 count, char *buffer); + virtual s32 ReadSectors2352(u32 sector, u32 count, char *buffer); + virtual s32 GetLayerBreakAddress(); + + virtual s32 GetMediaType(); + + virtual s32 IsOK(); + virtual s32 Reopen(); + + virtual s32 DiscChanged(); + + static Reader* TryLoad(const char* fileName); +}; \ No newline at end of file diff --git a/plugins/cdvdGigaherz/src/Windows/FileSrc.cpp b/plugins/cdvdGigaherz/src/Windows/PlainIso.cpp similarity index 78% rename from plugins/cdvdGigaherz/src/Windows/FileSrc.cpp rename to plugins/cdvdGigaherz/src/Windows/PlainIso.cpp index f568cacf39..6ac335dbfd 100644 --- a/plugins/cdvdGigaherz/src/Windows/FileSrc.cpp +++ b/plugins/cdvdGigaherz/src/Windows/PlainIso.cpp @@ -10,7 +10,11 @@ #pragma warning(default:4200) #include +#include "../ReaderModules.h" #include "../SectorConverters.h" + +#include + template bool ApiErrorCheck(T t,T okValue,bool cmpEq) { @@ -30,7 +34,7 @@ bool ApiErrorCheck(T t,T okValue,bool cmpEq) #define RETURN(v) {OpenOK=v; return;} -s32 FileSrc::Reopen() +s32 PlainIso::Reopen() { if(fileSource!=INVALID_HANDLE_VALUE) { @@ -53,7 +57,7 @@ s32 FileSrc::Reopen() return 0; } -FileSrc::FileSrc(const char* fileName) +PlainIso::PlainIso(const char* fileName) { fileSource=INVALID_HANDLE_VALUE; @@ -62,7 +66,7 @@ FileSrc::FileSrc(const char* fileName) Reopen(); } -FileSrc::~FileSrc() +PlainIso::~PlainIso() { if(OpenOK) { @@ -70,7 +74,7 @@ FileSrc::~FileSrc() } } -s32 FileSrc::GetSectorCount() +s32 PlainIso::GetSectorCount() { LARGE_INTEGER li; int plain_sectors = 0; @@ -88,12 +92,12 @@ s32 FileSrc::GetSectorCount() return -1; } -s32 FileSrc::GetLayerBreakAddress() +s32 PlainIso::GetLayerBreakAddress() { return 0; } -s32 FileSrc::GetMediaType() +s32 PlainIso::GetMediaType() { if(mediaTypeCached) return mediaType; @@ -125,7 +129,7 @@ s32 FileSrc::GetMediaType() f = ((l)%75); -s32 FileSrc::ReadTOC(char *toc,int msize) +s32 PlainIso::ReadTOC(char *toc,int msize) { DWORD size=0; @@ -162,7 +166,7 @@ s32 FileSrc::ReadTOC(char *toc,int msize) return 0; } -s32 FileSrc::ReadSectors2048(u32 sector, u32 count, char *buffer) +s32 PlainIso::ReadSectors2048(u32 sector, u32 count, char *buffer) { DWORD size=0; LARGE_INTEGER Offset; @@ -192,7 +196,7 @@ s32 FileSrc::ReadSectors2048(u32 sector, u32 count, char *buffer) } -s32 FileSrc::ReadSectors2352(u32 sector, u32 count, char *buffer) +s32 PlainIso::ReadSectors2352(u32 sector, u32 count, char *buffer) { DWORD size=0; LARGE_INTEGER Offset; @@ -228,7 +232,7 @@ s32 FileSrc::ReadSectors2352(u32 sector, u32 count, char *buffer) return 0; } -s32 FileSrc::DiscChanged() +s32 PlainIso::DiscChanged() { DWORD size=0; @@ -237,7 +241,23 @@ s32 FileSrc::DiscChanged() return 0; } -s32 FileSrc::IsOK() +s32 PlainIso::IsOK() { return OpenOK; } + +Reader* PlainIso::TryLoad(const char* fName) +{ + std::string fileName = fName; + std::string::size_type pos = fileName.find_last_of('.'); + + if(pos == std::string::npos) // no "." found, error. + return NULL; + + std::string extension = fileName.substr(pos); + + if(extension.compare(".iso")!=0) // assume valid + return NULL; + + return new PlainIso(fName); +} \ No newline at end of file diff --git a/plugins/cdvdGigaherz/src/Windows/cdvdGigaherz2008.vcproj b/plugins/cdvdGigaherz/src/Windows/cdvdGigaherz2008.vcproj index e0b2ff5db8..c1ebea976a 100644 --- a/plugins/cdvdGigaherz/src/Windows/cdvdGigaherz2008.vcproj +++ b/plugins/cdvdGigaherz/src/Windows/cdvdGigaherz2008.vcproj @@ -175,11 +175,11 @@ > + + + + + + @@ -207,22 +219,6 @@ RelativePath="..\SectorConverters.h" > - - - - - - - -