RageFileDriverProbe
authorPatrick McIlroy <itgpmc@gmail.com>
Wed, 22 Jul 2009 01:11:28 +0000 (01:11 +0000)
committerPatrick McIlroy <itgpmc@gmail.com>
Wed, 22 Jul 2009 01:11:28 +0000 (01:11 +0000)
git-svn-id: https://openitg.svn.sourceforge.net/svnroot/openitg@694 83fadc84-e282-4d84-a09a-c4228d6ae7e5

src/RageFileDriverProbe.cpp [new file with mode: 0644]

diff --git a/src/RageFileDriverProbe.cpp b/src/RageFileDriverProbe.cpp
new file mode 100644 (file)
index 0000000..25bd3a6
--- /dev/null
@@ -0,0 +1,42 @@
+#include "global.h"
+#include "RageFileDriverProbe.h"
+#include "RageFileDriverDirect.h"
+#include "RageFileDriverDirectHelpers.h"
+#include "RageFileManager.h"
+#include "RageLog.h"
+#include "RageUtil.h"
+#include "RageUtil_FileDB.h"
+
+REGISTER_FILE_DRIVER( Probe, "PRB" );
+
+// this function is to be error free
+//
+// if something fails, return RageFileObjDirect as fallback since it's going
+//  to fail anyway
+RageFileObjDirect *RageFileDriverProbe::CreateInternal( const CString &sPath )
+{
+       if (LOG)
+               LOG->Debug( "%s: sPath = %s", __FUNCTION__, sPath.c_str() );
+
+
+       RageFileObjDirect *rfod = new RageFileObjDirect;
+
+       int iErr;
+       if ( !rfod->OpenInternal( sPath, RageFile::READ, iErr ) )
+               return rfod;
+       int got = 0;
+       CString sHeader;
+       got = rfod->Read( sHeader, 2 );
+       SAFE_DELETE( rfod );
+
+       if ( sHeader == ":|" || sHeader == "8O" )
+       {
+               LOG->Debug( "%s: returning %s as RageFileObjCrypt_ITG2", __FUNCTION__, sPath.c_str() );
+               return new RageFileObjCrypt_ITG2( CRYPT_KEY );
+       }
+       else
+       {
+               LOG->Debug( "%s: returning %s as RageFileObjDirect", __FUNCTION__, sPath.c_str() );
+               return new RageFileObjDirect;
+       }
+}