📄 mm_file.c
字号:
__pMMFileRecord += wIdx;
switch(bMode)
{
// wyc2.60-909P, update the code for JPG rotate status because use attr for unicode checking.
case MM_GET_JPG_STATUS:
__bMMJPGStatus = (__pMMFileRecord->bFileAttr & ~IF_UNICODE_FILE_TAG);
break;
case MM_STORE_JPG_STATUS:
bTemp = __pMMFileRecord->bFileAttr & IF_UNICODE_FILE_TAG;
__pMMFileRecord->bFileAttr = __bMMJPGStatus;
__pMMFileRecord->bFileAttr |= bTemp;
break;
}
}
}
// ************************************************************************
// Function : MM_GetSRTRecord
// Description : Get the SRC file by input dir/file index.
// Arguments :
//
// Return : TRUE: There are SRT in input file, FALSE: There are no SRC in input file.
// Side Effect :
// ************************************************************************
#ifdef SUPPORT_CHAR_SUBPICTURE
BYTE MM_GetSRTRecord(PDWORD pdwSecLBA, PDWORD pdwSecNO, PBYTE bMP4SPType)
{
WORD dwMMTemp;
// wyc1.10-909, need to decrease __pMMVolumeDirTree[__MMSelectCursor.wDirID].bNoOfSubDir when compute the index of select cursor to get correct position.
// wyc2.17-909S, original way use select cursor index but it won't update when next/prev and number key. So now use __wPlayItem to get correct sub-title file.
dwMMTemp = MM_ID_RelativeToAbsolute(__MMSelectCursor.wDirID, __wPlayItem - 1);
// wyc1.11a, update code to support new mechanism parsing code.
if (((__pMMFileRecordStart[dwMMTemp].bFileAttr & ~IF_UNICODE_FILE_TAG) != 0x7F))// && (__SF_SourceGBL[__dwSFStreamID].bSourceIndex == SOURCE_DISC))
{
*pdwSecLBA = __pMMMP4SPRecord[__pMMFileRecordStart[dwMMTemp].bFileAttr & ~IF_UNICODE_FILE_TAG].dwBeginTime;
*pdwSecNO = __pMMMP4SPRecord[__pMMFileRecordStart[dwMMTemp].bFileAttr & ~IF_UNICODE_FILE_TAG].dwLen;
*bMP4SPType = __pMMMP4SPRecord[__pMMFileRecordStart[dwMMTemp].bFileAttr & ~IF_UNICODE_FILE_TAG].MP4SPName.bExtID;
return TRUE;
}
return FALSE;
}
#endif //SUPPORT_CHAR_SUBPICTURE
#ifdef SUPPORT_FILE_HANDLE
// LLY1.20 create
//###########################################################################
// Function : MM_GetFileRange
// Description : This function is used to get file range in sector unit
// Parameter : bID, specify the index within whole file structure
// Return : The file range (start + length)
// Side Effect :
//###########################################################################
FILE_RANGE MM_GetFileRange(WORD wID)
{
FILE_RANGE Range;
// Get file start sector
Range.dwStart = 0;
Range.dwStart |= __pMMFileRecordStart[wID].FileRange.cS[0];
Range.dwStart <<= 24;
Range.dwStart |= ((WORD)__pMMFileRecordStart[wID].FileRange.cS[1])<<16;
Range.dwStart |= ((WORD)__pMMFileRecordStart[wID].FileRange.cS[2])<<8;
Range.dwStart |= __pMMFileRecordStart[wID].FileRange.cS[3];
// Get file lenght in sector unit
Range.dwLen = __pMMFileRecordStart[wID].FileRange.dwLen;
return (Range);
}
// wyc1.20-909-searchfile,
// ************************************************************************
// Function : MM_SearchFileByFileRecord
// Description : Find the request file by input path. Then report the offset
// in file record in this request file.
// Arguments : pFileName: Search file name. wFileOffset: The offset in file record in this file.
// Return : TRUE: File found. FALSE: File not found.
// Side Effect :
// ************************************************************************
BYTE MM_SearchFileByFileRecord(char* pFilePathName, WORD* wFileOffset)
{
char pName[SUPPORT_DIR_LENGTH];
// step1, to get the depth of dir.
// use _dwMMTemp2 to represnt the dir depth in input file path.
_dwMMTemp2= 0;
// begin from 2 is because ROOT use "//" to represent, so we can skip ROOT string and begin from dir path.
for (_dwMMTemp1=2; _dwMMTemp1<FILE_HANDLE_DEPTH_OF_FILE_PATH; _dwMMTemp1++)
{
if (pFilePathName[_dwMMTemp1] == '/')
_dwMMTemp2++;
}
_dwMMTemp3 = 2;
// Using to indicate the ID of match dir name in file record for searching correct dir path.
_dwMMTemp5 = 0;
while (_dwMMTemp2--)
{
// search the char '/' to find the dir name.
for (_dwMMTemp1=_dwMMTemp3; _dwMMTemp1<FILE_HANDLE_DEPTH_OF_FILE_PATH; _dwMMTemp1++)
{
if (pFilePathName[_dwMMTemp1] == '/')
{
// _dwMMTemp4 is the length of current parsed dir name.
_dwMMTemp4 = _dwMMTemp1 - _dwMMTemp3;
// copy the dir name in path to temp buffer for compare usage.
strncpy(pName,pFilePathName+_dwMMTemp3,_dwMMTemp4);
pName[_dwMMTemp4] = 0;
// _dwMMTemp3 mean the next search dir name in input path.
_dwMMTemp3 = _dwMMTemp1+1;
break;
}
}
// start to compare the dir name in path & dir name in dirnamelist.
_dwMMTemp6 = (__pMMVolumeDirTree[_dwMMTemp5].b1stSubDirID+__pMMVolumeDirTree[_dwMMTemp5].bNoOfSubDir);
for (_dwMMTemp1=__pMMVolumeDirTree[_dwMMTemp5].b1stSubDirID; _dwMMTemp1<_dwMMTemp6; _dwMMTemp1++)
{
// the dir name in input path matched with the dir name file record.
if (!strcmp(__pMMDirNameList[_dwMMTemp1].cName,pName))
{
_dwMMTemp5 = _dwMMTemp1;
break;
}
}
// mean input dir path don't patch the dir in file record.
if (_dwMMTemp1 >= _dwMMTemp6)
return FALSE;
}
// need to check the file name in input path and copy file name in input path to pName.
for (_dwMMTemp1=_dwMMTemp3; _dwMMTemp1<FILE_HANDLE_DEPTH_OF_FILE_PATH; _dwMMTemp1++)
{
if (pFilePathName[_dwMMTemp1] == '.')
{
// _dwMMTemp2 used to record the end of file name.
_dwMMTemp2 = _dwMMTemp1;
}
else if (pFilePathName[_dwMMTemp1] == 0)
break;
}
// (_dwMMTemp2-_dwMMTemp3) is the length of file name in input path.
strncpy(pName,pFilePathName+_dwMMTemp3,_dwMMTemp2-_dwMMTemp3);
COMUTL_StrUpr((char*)(pFilePathName+_dwMMTemp2+1));
// _dwMMTemp4 used to indicate the ext ID of input path file.
_dwMMTemp4 = CD_CheckExtName(pFilePathName+_dwMMTemp2+1);
MM_TriggerDumping(MM_ID_RelativeToAbsolute(_dwMMTemp5, 0), __pMMFilesOfDir[_dwMMTemp5]);
for (_dwMMTemp1=0; _dwMMTemp1<__pMMFilesOfDir[_dwMMTemp5]; _dwMMTemp1++)
{
if (MM_GetDumpedFileRecord() == MM_FILE_RECORD_DUMP_FAILED)
return FALSE;
if ((!strncmp(__pMMFileRecord->FileName.cName, pName, _dwMMTemp2-_dwMMTemp3)) && (_dwMMTemp4 == __pMMFileRecord->FileName.bExtID))
{
// file in file record match as input path file name. Ext name also matched.
*wFileOffset = MM_ID_RelativeToAbsolute(_dwMMTemp5,_dwMMTemp1);
return TRUE;
}
}
return FALSE;
}
#endif // SUPPORT_FILE_HANDLE
// *********************************************************************
// Function : MM_ID_AbsoluteToRelative
// Description : convert absolute ID to relative ID of file record.
// Arguments : wAbsID: Absolute ID
// Return : Return the relative ID
// Remark : This function only work in directory boundary, can't across boundary.
// Side Effect :
// *********************************************************************
WORD MM_ID_AbsoluteToRelative(DWORD bAbsID)
{
__pMMFileRecordTemp = __pMMFileRecordStart;
_dwMMTemp3 = __pMMDirNameList[__MMPlayingItem.wDirID].wMMFileRecordEntry;
if (_dwMMTemp3 == bAbsID)
return (0);
for (_dwMMTemp6=0; _dwMMTemp6< __pMMFilterFilesOfDir[__MMPlayingItem.wDirID]; _dwMMTemp6++)
{
_dwMMTemp3 = __pMMFileRecordTemp[_dwMMTemp3].wNextFileRecord;
if (_dwMMTemp3 == bAbsID)
break;
}
_dwMMTemp6++;
return (_dwMMTemp6);
}
// *********************************************************************
// Function : MM_ID_RelativeToAbsolute
// Description : convert relative ID to absolute ID of file record.
// Arguments : bDirID: Directory index. wRelID: Relative ID in this directory.
// Return : Return the absolute ID
// Side Effect :
// *********************************************************************
WORD MM_ID_RelativeToAbsolute(BYTE bDirID, WORD wRelID)
{
DWORD dwMMTemp;
// Chuan0.85, Use the definition of CTKAV.H
__pMMFileRecord = (PFILE_RECORD)__pMMFileRecordStart;
if (__bMMSortSequence == MM_SORT_BY_ASCENDING)
{
_dwMMLastAbsID = __pMMDirNameList[bDirID].wMMFileRecordEntry;
for (dwMMTemp = 0; dwMMTemp<wRelID; dwMMTemp++)
_dwMMLastAbsID = __pMMFileRecord[_dwMMLastAbsID].wNextFileRecord;
}
else if (__bMMSortSequence == MM_SORT_BY_DESCENDING)
{
_dwMMLastAbsID = __pMMDirNameList[bDirID].wMMFileRecordEnd;
for (dwMMTemp = 0; dwMMTemp<wRelID; dwMMTemp++)
_dwMMLastAbsID = __pMMFileRecord[_dwMMLastAbsID].wPrevFileRecord;
}
return (WORD)_dwMMLastAbsID;
}
// *********************************************************************
// Function : MM_TriggerDumping
// Description : Function to trigger file record dumping by absolute index.
// Arguments : wAbsID: Dump file record from input absolute ID. wNum: The expected number of file record dumping.
// Return : None
// Side Effect :
// *********************************************************************
void MM_TriggerDumping(WORD wAbsID, WORD wNum)
{
_wStartDumpAbsID = wAbsID;
if ((__pMMFileRecord[wAbsID].wPrevFileRecord == FILE_RECORD_NONE) && (__pMMFileRecord[wAbsID].wNextFileRecord == FILE_RECORD_NONE))
_wMMUnDumpFileRecord = 0;
else
_wMMUnDumpFileRecord = wNum;
_bMMFirstDumped = TRUE;
_wNextFileRecord = 0;
return;
}
// *********************************************************************
// Function : MM_GetDumpedFileRecord
// Description : Function to dump file record one by one after issuing function MM_TriggerDumping
// Arguments : pFileRecord: Output dumped file record.
// Return : Return the un-dumped file record number
// Side Effect :
// *********************************************************************
WORD MM_GetDumpedFileRecord(void)
{
if ((_wMMUnDumpFileRecord == 0) || (_wNextFileRecord == FILE_RECORD_END))
return MM_FILE_RECORD_DUMP_FAILED;
// wyc0.65, suppose all cases need to do follow code.
// Chuan0.85, Use the definition of CTKAV.H
__pMMFileRecord = (PFILE_RECORD)__pMMFileRecordStart;
if (_bMMFirstDumped)
{
__pMMFileRecord = __pMMFileRecord + _wStartDumpAbsID;
_bMMFirstDumped = FALSE;
}
else
{
__pMMFileRecord = __pMMFileRecord + _wNextFileRecord;
}
_wMMUnDumpFileRecord--;
if (__bMMSortSequence == MM_SORT_BY_ASCENDING)
_wNextFileRecord = __pMMFileRecord->wNextFileRecord;
else
_wNextFileRecord = __pMMFileRecord->wPrevFileRecord;
return _wMMUnDumpFileRecord;
}
BYTE _MM_SortFilterFiles(WORD wDirID, BYTE bFilterMode, BYTE bSortMode)
{
DWORD dwMMMinVal, dwMMMinIndex, dwMMPreMinIndex;
DWORD dwMMDirOffset, dwMMDiscMinIndex, dwMMDiscPreMinIndex;
// don't need to sort/filter dir when no files in it.
if (__pMMFilesOfDir[wDirID] == 0)
{
__pMMDirNameList[wDirID].bMMLinkStatus |= MM_SORT_FILTER_LINK_READY;
__pMMFilterFilesOfDir[wDirID] = 0; //CoCo2.38
return TRUE;
}
if ((__bMMPreExtFilterMode == bFilterMode) && (__bMMPreSortMethod == bSortMode) && (__pMMDirNameList[wDirID].bMMLinkStatus & MM_SORT_FILTER_LINK_READY) && (__wMMPreFilterDir == wDirID))
return TRUE;
// Chuan0.85, Use the definition of CTKAV.H
__pMMFileRecord = (PFILE_RECORD)__pMMFileRecordStart;
_dwMMTemp=(DWORD)MM_IndexConvert(MM_INDEX_CONVERT_DIR2DISC, wDirID, 0);
// doing sorting function
if (__bMMSortMethod == MM_SORT_BY_NAME)
{
__pMMFileRecord += _dwMMTemp;
_dwMMTemp3 = _dwMMTemp;
_dwMMTemp1 = __pMMFilesOfDir[wDirID];
for (_dwMMTemp=0; _dwMMTemp<_dwMMTemp1; _dwMMTemp++)
{
if (_dwMMTemp==0)
{
__pMMFileRecord[_dwMMTemp].wNextFileRecord = _dwMMTemp+_dw
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -