void isoFile::Open( const wxString& srcfile ) { Close(); m_filename = srcfile; m_parts[0].handle = new wxFileInputStream( m_filename ); pxStream_OpenCheck( *m_parts[0].handle, m_filename, L"reading" ); m_numparts = 1; m_parts[0].slsn = 0; // elsn is unknown at this time, but is also unused when m_numparts == 1. // (and if numparts is incremented, elsn will get assigned accordingly) if (!Detect()) throw Exception::BadStream() .SetUserMsg(_("Unrecognized ISO image file format")) .SetDiagMsg(L"ISO mounting failed: PCSX2 is unable to identify the ISO image type."); if (!(m_flags & ISOFLAGS_BLOCKDUMP_V2)) { m_blocks = m_parts[0].CalculateBlocks( 0, m_blocksize ); FindParts(); if (m_numparts > 1) { Console.WriteLn( Color_Blue, "isoFile: multi-part ISO detected. %u parts found." ); } } const char* isotypename = NULL; switch(m_type) { case ISOTYPE_CD: isotypename = "CD"; break; case ISOTYPE_DVD: isotypename = "DVD"; break; case ISOTYPE_AUDIO: isotypename = "Audio CD"; break; case ISOTYPE_DVDDL: isotypename = "DVD9 (dual-layer)"; break; case ISOTYPE_ILLEGAL: default: isotypename = "illegal media"; break; } Console.WriteLn(Color_StrongBlue, L"isoFile open ok: %s", m_filename.c_str()); ConsoleIndentScope indent; Console.WriteLn("Image type = %s", isotypename); Console.WriteLn("Fileparts = %u", m_numparts); DevCon.WriteLn ("blocks = %u", m_blocks); DevCon.WriteLn ("offset = %d", m_offset); DevCon.WriteLn ("blocksize = %u", m_blocksize); DevCon.WriteLn ("blockoffset = %d", m_blockofs); }
// multi-part ISO support is provided for FAT32 compatibility; so that large 4GB+ isos // can be split into multiple smaller files. // // Returns TRUE if multiple parts for the ISO are found. Returns FALSE if only one // part is found. void isoFile::FindParts() { wxFileName nameparts( m_filename ); wxString curext( nameparts.GetExt() ); wxChar prefixch = wxTolower(curext[0]); // Multi-part rules! // * The first part can either be the proper extension (ISO, MDF, etc) or the numerical // extension (I00, I01, M00, M01, etc). // * Numerical extensions MUST begin at 00 (I00 etc), regardless of if the first part // is proper or numerical. uint i = 0; if ((curext.Length() == 3) && (curext[1] == L'0') && (curext[2] == L'0')) { // First file is an OO, so skip 0 in the loop below: i = 1; } FastFormatUnicode extbuf; extbuf.Write( L"%c%02u", prefixch, i ); nameparts.SetExt( extbuf ); if (!pxFileExists_WithExt(nameparts, extbuf)) return; DevCon.WriteLn( Color_Blue, "isoFile: multi-part %s detected...", curext.Upper().c_str() ); ConsoleIndentScope indent; for (; i < MaxSplits; ++i) { extbuf.Clear(); extbuf.Write( L"%c%02u", prefixch, i ); if (!pxFileExists_WithExt(nameparts, extbuf)) break; _IsoPart& thispart( m_parts[m_numparts] ); thispart.handle = new wxFileInputStream( nameparts.GetFullPath() ); pxStream_OpenCheck( *thispart.handle, nameparts.GetFullPath(), L"reading" ); m_blocks += thispart.CalculateBlocks( m_blocks, m_blocksize ); DevCon.WriteLn( Color_Blue, L"\tblocks %u - %u in: %s", thispart.slsn, thispart.elsn, nameparts.GetFullPath().c_str() ); ++m_numparts; } //Console.WriteLn( Color_Blue, "isoFile: multi-part ISO loaded (%u parts found)", m_numparts ); }
void isoFile::Create(const wxString& filename, int flags) { Close(); m_filename = filename; m_flags = flags; m_offset = 0; m_blockofs = 24; m_blocksize = 2048; m_outstream = new wxFileOutputStream( m_filename ); pxStream_OpenCheck( *m_outstream, m_filename, L"writing" ); Console.WriteLn("isoFile create ok: %s ", m_filename.c_str()); }
void OutputIsoFile::Create(const wxString& filename, int version) { Close(); m_filename = filename; m_version = version; m_offset = 0; m_blockofs = 24; m_blocksize = 2048; m_outstream = std::make_unique<wxFileOutputStream>(m_filename); pxStream_OpenCheck( *m_outstream, m_filename, L"writing" ); Console.WriteLn("isoFile create ok: %s ", WX_STR(m_filename)); }
// Tests the specified filename to see if it is a supported ISO type. This function typically // executes faster than isoFile::Open since it does not do the following: // * check for multi-part ISOs. I tests for header info in the main/root ISO only. // * load blockdump indexes. // // Note that this is a member method, and that it will clobber any existing ISO state. // (assertions are generated in debug mode if the object state is not already closed). bool isoFile::Test( const wxString& srcfile ) { pxAssertMsg( !m_parts[0].handle, "Warning! isoFile::Test is about to clobber whatever existing iso bound to this isoFile object!" ); Close(); m_filename = srcfile; m_parts[0].handle = new wxFileInputStream( m_filename ); pxStream_OpenCheck( *m_parts[0].handle, m_filename, L"reading" ); m_numparts = 1; m_parts[0].slsn = 0; // elsn is unknown at this time, but is also unused when m_numparts == 1. // (and if numparts is incremented, elsn will get assigned accordingly) return Detect( false ); }