예제 #1
0
	void readFile()
	{
		int rsize = 0;
		if ((strnicmp( filename.c_str(), "cdrom0:", strlen("cdromN:")) == 0) ||
			(strnicmp( filename.c_str(), "cdrom1:", strlen("cdromN:")) == 0))
		{
			int fi;
			fi = CDVDFS_open(filename.c_str() + strlen("cdromN:"), 1);//RDONLY
			if (fi < 0)
				throw Exception::FileNotFound( filename );
			CDVDFS_lseek( fi, 0, SEEK_SET );
			rsize = CDVDFS_read( fi, (char*)data.GetPtr(), data.GetSizeInBytes() );
			CDVDFS_close( fi );
		}
		else
		{
			FILE *f;

			f = fopen( filename.c_str(), "rb" );
			if( f == NULL )
				Exception::FileNotFound( filename );
			fseek( f, 0, SEEK_SET );
			rsize = fread( data.GetPtr(), 1, data.GetSizeInBytes(), f );
			fclose( f );
		}

		if( rsize < data.GetSizeInBytes() )
			throw Exception::EndOfStream( filename );
	}
예제 #2
0
	u32 GetCRC() const
	{
		u32 CRC = 0;

		const  u32* srcdata = (u32*)data.GetPtr();
		for(u32 i=data.GetSizeInBytes()/4; i; --i, ++srcdata)
			CRC ^= *srcdata;

		return CRC;
	}