Core/burner/cocoa/neocdlist.cpp
// Check the specified ISO, and proceed accordingly
Check the specified ISO, and proceed accordingly
Check the specified ISO and proceed accordingly
static int NeoCDList_CheckISO(TCHAR* pszFile)
{
	if(!pszFile) {
		return 0;
	}
	if(_tcsstr(pszFile, _T(".iso")) || _tcsstr(pszFile, _T(".ISO")) ) 
	{
		FILE* fp = _tfopen(pszFile, _T("rb"));
		if(fp) 
		{
			fseek(fp, 0, SEEK_END);
			unsigned int lSize = 0;
			lSize = ftell(fp);
			fseek(fp, 0, SEEK_SET);
			if(lSize > (2048 * 16)) 
			{	
				unsigned char IsoHeader[2048 * 16 + 1];
				unsigned char IsoCheck[6];
				fread(IsoHeader, 1, 2048 * 16 + 1, fp); 
				fread(IsoCheck, 1, 5, fp);	
				if(!memcmp(IsoCheck, "CD001", 5))
				{
					iso9660_VDH vdh;
					memset(&vdh, 0, sizeof(vdh));
					iso9660_ReadOffset((unsigned char*)&vdh, fp, 2048 * 16, 1, sizeof(vdh));
					if(vdh.vdtype == 0x01) 
					{
#if 0
						iso9660_PVD pvd;
						memset(&pvd, 0, sizeof(pvd));
						iso9660_ReadOffset((unsigned char*)&pvd, fp, 2048 * 16, 1, sizeof(pvd));
						char szRootSector[32];
						unsigned int nRootSector = 0;
						sprintf(szRootSector, "%02X%02X%02X%02X", 
							pvd.root_directory_record.location_of_extent[4], 
							pvd.root_directory_record.location_of_extent[5], 
							pvd.root_directory_record.location_of_extent[6], 
							pvd.root_directory_record.location_of_extent[7]);
						sscanf(szRootSector, "%X", &nRootSector);
#else
						unsigned char buffer[8];
						char szRootSector[4];
						unsigned int nRootSector = 0;
						fseek(fp, 0x809e, SEEK_SET);
						fread(buffer, 1, 8, fp);
						sprintf(szRootSector, "%02x%02x%02x%02x", buffer[4], buffer[5], buffer[6], buffer[7]);
						sscanf(szRootSector, "%x", &nRootSector);
#endif						
						NeoCDList_iso9660_CheckDirRecord(fp, nRootSector);
					}
				} else {
					return 0;
				}
			}
		} else {
			return 0;
		}
		if(fp) fclose(fp);
	} else {
		return 0;
	}
	return 1;
}
static int NeoCDList_CheckISO ( TCHAR * pszFile ) { if ( ! pszFile ) { return 0 ; } if ( _tcsstr ( pszFile , _T ( " " ) ) || _tcsstr ( pszFile , _T ( " " ) ) ) { FILE * fp = _tfopen ( pszFile , _T ( " " ) ) ; if ( fp ) { fseek ( fp , 0 , SEEK_END ) ; unsigned int lSize = 0 ; lSize = ftell ( fp ) ; fseek ( fp , 0 , SEEK_SET ) ; if ( lSize > ( 2048 * 16 ) ) { unsigned char IsoHeader [ 2048 * 16 + 1 ] ; unsigned char IsoCheck [ 6 ] ; fread ( IsoHeader , 1 , 2048 * 16 + 1 , fp ) ; fread ( IsoCheck , 1 , 5 , fp ) ; if ( ! memcmp ( IsoCheck , " " , 5 ) ) { iso9660_VDH vdh ; memset ( & vdh , 0 , sizeof ( vdh ) ) ; iso9660_ReadOffset ( ( unsigned char * ) & vdh , fp , 2048 * 16 , 1 , sizeof ( vdh ) ) ; if ( vdh . vdtype == 0x01 ) { #if 0 iso9660_PVD pvd ; memset ( & pvd , 0 , sizeof ( pvd ) ) ; iso9660_ReadOffset ( ( unsigned char * ) & pvd , fp , 2048 * 16 , 1 , sizeof ( pvd ) ) ; char szRootSector [ 32 ] ; unsigned int nRootSector = 0 ; sprintf ( szRootSector , " " , pvd . root_directory_record . location_of_extent [ 4 ] , pvd . root_directory_record . location_of_extent [ 5 ] , pvd . root_directory_record . location_of_extent [ 6 ] , pvd . root_directory_record . location_of_extent [ 7 ] ) ; sscanf ( szRootSector , " " , & nRootSector ) ; #else unsigned char buffer [ 8 ] ; char szRootSector [ 4 ] ; unsigned int nRootSector = 0 ; fseek ( fp , 0x809e , SEEK_SET ) ; fread ( buffer , 1 , 8 , fp ) ; sprintf ( szRootSector , " " , buffer [ 4 ] , buffer [ 5 ] , buffer [ 6 ] , buffer [ 7 ] ) ; sscanf ( szRootSector , " " , & nRootSector ) ; #endif NeoCDList_iso9660_CheckDirRecord ( fp , nRootSector ) ; } } else { return 0 ; } } } else { return 0 ; } if ( fp ) fclose ( fp ) ; } else { return 0 ; } return 1 ; }
Check the specified ISO, and proceed accordingly
Check the specified ISO and proceed accordingly
// error // Make sure we have a valid ISO file extension... // Read ISO and look for 68K ROM standard program header, ID is always there // Note: This function works very quick, doesn't compromise performance :) // it just read each sector first 264 bytes aproximately only. // Get ISO Size (bytes) //rewind(fp); // If it has at least 16 sectors proceed // Check for Standard ISO9660 Identifier // advance to sector 16 and PVD Field 2 // get Standard Identifier Field from PVD // Verify that we have indeed a valid ISO9660 MODE1/2048 //bprintf(PRINT_NORMAL, _T("    Standard ISO9660 Identifier Found. \n")); // Get Volume Descriptor Header			 //memcpy(&vdh, iso9660_ReadOffset(fp, (2048 * 16), sizeof(vdh)), sizeof(vdh)); // Check for a valid Volume Descriptor Type // This will fail on 64-bit due to differing variable sizes in the pvd struct // Get Primary Volume Descriptor //memcpy(&pvd, iso9660_ReadOffset(fp, (2048 * 16), sizeof(pvd)), sizeof(pvd)); // ROOT DIRECTORY RECORD // Handle Path Table Location // Convert HEX string to Decimal // Just read from the file directly at the correct offset (0x8000 + 0x9e for the start of the root directory record) // Process the Root Directory Records // Path Table Records are not processed, since NeoGeo CD should not have subdirectories // ... //bprintf(PRINT_NORMAL, _T("    Standard ISO9660 Identifier Not Found, cannot continue. \n")); //bprintf(PRINT_NORMAL, _T("    Couldn't open %s \n"), GetIsoPath()); //bprintf(PRINT_NORMAL, _T("    File doesn't have a valid ISO extension [ .iso / .ISO ] \n"));