📄 diskinfo.cpp
字号:
}
BOOLEAN cDiskInfo::IsHDDVD(LOADER_HANDLE tLoader, BOOLEAN &fAdvancedContent)
{
BYTE bExists = 0;
BOOLEAN fIsHDDVD = FALSE;
LOADER_FILE_HANDLE hFileVMGI = 0;
char cVMG_ID[12];
BOOLEAN fBackup = FALSE;
LOADER_ERR ret;
/* Check if "DISCID.DAT" exists in "ADV_OBJ" directory */
if (LoaderFileAccess(tLoader, "/mnt/cdrom/ADV_OBJ/DISCID.DAT", LOADER_FILE_ACCESS_EXIST, &bExists) != LOADER_SUCCESS)
{
DbgPrint(("cDiskInfo::IsHDDVD() -- LoaderFileAccess() FAILED!\n"));
bExists = 0;
}
/*
* If "DISCID.DAT" exists in the "ADV_OBJ" directory, then this is a category 2 or
* category 3 HD-DVD disc. Otherwise, it may be a category 1 disc, so do more checking.
*/
if (bExists)
{
fIsHDDVD = TRUE;
fAdvancedContent = TRUE;
}
else
{
fAdvancedContent = FALSE;
/* Check if Video Manager Information file exists */
if (LoaderFileAccess(tLoader, "/mnt/cdrom/HVDVD_TS/HV000I01.IFO", LOADER_FILE_ACCESS_EXIST, &bExists) != LOADER_SUCCESS)
{
DbgPrint(("cDiskInfo::IsHDDVD() -- LoaderFileAccess() FAILED!\n"));
bExists = 0;
}
/* If main VMGI file does not exist, try backup */
if (bExists == 0)
{
fBackup = TRUE;
/* Check if Video Manager Information file exists */
if (LoaderFileAccess(tLoader, "/mnt/cdrom/HVDVD_TS/HV000I01.BUP", LOADER_FILE_ACCESS_EXIST, &bExists) != LOADER_SUCCESS)
{
DbgPrint(("cDiskInfo::IsHDDVD() -- LoaderFileAccess() FAILED!\n"));
bExists = 0;
}
}
if (bExists)
{
/* Open the Video Manager Information file */
if (fBackup)
{
ret = LoaderFileOpen(tLoader, "/mnt/cdrom/HVDVD_TS/HV000I01.BUP", &hFileVMGI);
}
else
{
ret = LoaderFileOpen(tLoader, "/mnt/cdrom/HVDVD_TS/HV000I01.IFO", &hFileVMGI);
}
if (ret == LOADER_SUCCESS)
{
/* Read the first 12 bytes (VMG_ID) from VMGI file */
if (LoaderFileRead(tLoader, hFileVMGI, (PVOID)cVMG_ID, 12, NULL) != LOADER_SUCCESS)
{
DbgPrint(("cDiskInfo::IsHDDVD() -- Failed to read file!\n"));
}
else
{
/* Check VMG_ID to determine if this disc is an HD-DVD Category 1 disc */
if (strncmp("HVDVD-VMG100", cVMG_ID, 12) == 0)
{
fIsHDDVD = TRUE;
}
}
}
}
}
/* Close VMGI file */
if (hFileVMGI)
{
LoaderFileClose(tLoader, hFileVMGI);
}
return (fIsHDDVD);
}
BOOLEAN cDiskInfo::IsBDROM(LOADER_HANDLE tLoader)
{
BYTE bExists = 1;
/*
* Try to access all required directories and files. If any are missing,
* then this is not a valid BDROM media format.
*/
/* Check for index database */
if (LoaderFileAccess(tLoader, "/mnt/cdrom/BDMV/index.bdmv", LOADER_FILE_ACCESS_EXIST, &bExists) != LOADER_SUCCESS)
{
bExists = 0;
}
/* if main index db doesn't exist, try backup */
if (bExists == 0)
{
if (LoaderFileAccess(tLoader, "/mnt/cdrom/BDMV/BACKUP/index.bdmv", LOADER_FILE_ACCESS_EXIST, &bExists) != LOADER_SUCCESS)
{
bExists = 0;
}
if (bExists == 0)
{
goto exit;
}
}
/* Check for movie object database */
if (LoaderFileAccess(tLoader, "/mnt/cdrom/BDMV/MovieObject.bdmv", LOADER_FILE_ACCESS_EXIST, &bExists) != LOADER_SUCCESS)
{
bExists = 0;
}
/* if main movie object db doesn't exist, try backup */
if (bExists == 0)
{
if (LoaderFileAccess(tLoader, "/mnt/cdrom/BDMV/BACKUP/MovieObject.bdmv", LOADER_FILE_ACCESS_EXIST, &bExists) != LOADER_SUCCESS)
{
bExists = 0;
}
if (bExists == 0)
{
goto exit;
}
}
/* Check for clip info */
if (LoaderFileAccess(tLoader, "/mnt/cdrom/BDMV/CLIPINF", LOADER_FILE_ACCESS_EXIST, &bExists) != LOADER_SUCCESS)
{
bExists = 0;
}
/* if main clininfo doesn't exist, try backup */
if (bExists == 0)
{
if (LoaderFileAccess(tLoader, "/mnt/cdrom/BDMV/BACKUP/CLIPINF", LOADER_FILE_ACCESS_EXIST, &bExists) != LOADER_SUCCESS)
{
bExists = 0;
}
if (bExists == 0)
{
goto exit;
}
}
/* Check for playlist */
if (LoaderFileAccess(tLoader, "/mnt/cdrom/BDMV/PLAYLIST", LOADER_FILE_ACCESS_EXIST, &bExists) != LOADER_SUCCESS)
{
bExists = 0;
}
/* if main playlist directory doesn't exist, try backup */
if (bExists == 0)
{
if (LoaderFileAccess(tLoader, "/mnt/cdrom/BDMV/BACKUP/PLAYLIST", LOADER_FILE_ACCESS_EXIST, &bExists) != LOADER_SUCCESS)
{
bExists = 0;
}
if (bExists == 0)
{
goto exit;
}
}
/* Check for stream directory */
if (LoaderFileAccess(tLoader, "/mnt/cdrom/BDMV/STREAM", LOADER_FILE_ACCESS_EXIST, &bExists) != LOADER_SUCCESS)
{
bExists = 0;
}
if (bExists == 0)
{
goto exit;
}
/* Check for auxdata */
if (LoaderFileAccess(tLoader, "/mnt/cdrom/BDMV/AUXDATA", LOADER_FILE_ACCESS_EXIST, &bExists) != LOADER_SUCCESS)
{
bExists = 0;
}
exit:
/*
* If all required directories and files exist, disc is BDROM.
* Otherwise, it is not.
*/
if (bExists != 0)
{
return (TRUE);
}
else
{
return (FALSE);
}
}
BOOLEAN cDiskInfo::IsDVD_V(LOADER_HANDLE tLoader)
{
return (ReaddirIsVidTS(tLoader));
}
BOOLEAN cDiskInfo::IsDVD_A(LOADER_HANDLE tLoader)
{
return (ReaddirIsAudTS(tLoader));
}
BOOLEAN cDiskInfo::IsCDDA(BYTE bDiskType, BYTE bControl)
{
return ( (bDiskType == 0) && ( (bControl & 0xc) == 0) );
}
BOOLEAN cDiskInfo::IsMP3(LOADER_HANDLE tLoader, BYTE bDiskType, BYTE bControl)
{
if ( (bDiskType == 0) && ( (bControl & 0xc) == 4) )
{
/* TODO: it's a cd-rom, now check if there's mp3 info on it. if so, return true */
/* (for now, always return true) */
return(TRUE);
}
else
{
return(FALSE);
}
}
BOOLEAN cDiskInfo::IsVCD(LOADER_HANDLE tLoader, BYTE bDiskType)
{
if ( bDiskType == 0x20 )
{
/* clear the buffer to prevent false VCD detection */
memset(bScratchPadBuffer, 0, 16);
/* read the sector */
LoaderCDRead(tLoader, 150, 1, LOADER_CD_SECTOR_MODE2_FORM1, LOADER_CDDS_USER, bScratchPadBuffer, SCRATCHSIZE);
/* check the results */
if ( ( 0 == strncmp((char *)bScratchPadBuffer, "SUPERVCD", 8) ) ||
( 0 == strncmp((char *)bScratchPadBuffer, "VIDEO_CD", 8) ) ||
( 0 == strncmp((char *)bScratchPadBuffer, "HQ-VCD ", 8) ) )
{
return (TRUE);
}
}
return (FALSE);
}
BOOLEAN cDiskInfo::IsSVCD(LOADER_HANDLE tLoader, BYTE bDiskType)
{
if ( bDiskType == 0x20 )
{
/* clear the buffer to prevent false VCD detection */
memset(bScratchPadBuffer, 0, 16);
/* read the sector */
LoaderCDRead(tLoader, 150, 1, LOADER_CD_SECTOR_MODE2_FORM1, LOADER_CDDS_USER, bScratchPadBuffer, SCRATCHSIZE);
/* check the results */
if ( ( 0 == strncmp((char *)bScratchPadBuffer, "SUPERVCD", 8) ) )
{
return (TRUE);
}
}
return (FALSE);
}
BOOLEAN cDiskInfo::IsVR(LOADER_HANDLE tLoader)
{
BYTE bExists = 1;
/*
* Try to access all required directories and files. If any are missing,
* then this is not a valid DVD-VR media format.
*/
if (LoaderFileAccess(tLoader, "/mnt/cdrom/DVD_RTAV/VR_MANGR.IFO", LOADER_FILE_ACCESS_EXIST, &bExists) != LOADER_SUCCESS)
{
bExists=0;
}
return (bExists?TRUE:FALSE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -