📄 mfm47readaddr.c
字号:
#ifdef FSS_FTR#define ACCESS_RIGHTS_INTERNAL_MFM#define MFM45READDIR_C#include "mFm.h"#undef FILE_NUMBER#define FILE_NUMBER 45 #undef PROCEDURE_NUMBER #define PROCEDURE_NUMBER 1void mFm47_01GetFilesAddr( void * pp_LayerContext, void * pp_Param ){ t_fs_llGetFilesAddr * pl_Param = (t_fs_llGetFilesAddr *) pp_Param; u32 vl_UsedBufferSize; /* Is it a single address read ? */ if ( pl_Param->v_Type == FS_READ_SINGLE_ADDR_WITH_ID ) { u16 vl_FileID; u16 vl_NbrFilesGot; /* Yes so call VM to have address of this file */ vl_FileID = pl_Param->v_Id; MC_MFM_LL_GET_FILES_ADDR( 1, &vl_FileID, NIL, 0, &vl_NbrFilesGot, pl_Param->p_FileAddr, &vl_UsedBufferSize, pl_Param->p_Status ); } else /* It is a directory's objects address read */ { t_OpenedDirCtx * pl_DirCtx = ( t_OpenedDirCtx *) pl_Param->p_FmPrivateDirInfo; t_OpenedDirCtx sl_DirCtx; s32 vl_NbFilesToGet = 0; u32 vl_DestBuffSize = pl_Param->v_BuffSize; ascii * pl_ReadBuff; t_fssFileAddr * pl_CurrentFileAddr = * pl_Param->p_FileAddr; t_fssFileAddr * pl_OutFileAddr; s32 vl_TotalNbFilesGot = 0; u16 * pl_IdTab; t_WhichType vl_Which; u16 vl_NbFilesGot; u8 vl_ExitReq = FALSE; if ( pl_Param->v_NumbFilesToGet >= MFM_ID_TAB_SIZE ) pl_IdTab = ( u16 *) MC_MFM_GET_MEMORY( sizeof (u16) * MFM_ID_TAB_SIZE ); else pl_IdTab = ( u16 *) MC_MFM_GET_MEMORY( sizeof (u16) * pl_Param->v_NumbFilesToGet ); /* Get memory for read buffer */ pl_ReadBuff = (ascii*) MC_MFM_GET_MEMORY( MFM_SIZE_OF_READ_BUFF ); /* Clear number of files got */ vl_NbFilesGot = 0; /* Updates which structure */ vl_Which.v_Position = pl_Param->v_Which; /* Take position */ vl_Which.v_TypeOfObj = FM_OBJ_FILE; /* Only files */ vl_Which.v_InfoType = FM_ID; /* Place IDs in destination table */ while ( ( vl_TotalNbFilesGot < pl_Param->v_NumbFilesToGet ) && ( vl_ExitReq == FALSE ) ) { /* Clear number of files got */ vl_NbFilesGot = 0; /* Calculates number of files to get for this iteration */ vl_NbFilesToGet = pl_Param->v_NumbFilesToGet - vl_TotalNbFilesGot; if ( vl_NbFilesToGet > MFM_ID_TAB_SIZE ) vl_NbFilesToGet = MFM_ID_TAB_SIZE; else vl_ExitReq = TRUE; /* Save directory context before to read IDs */ sl_DirCtx = * pl_DirCtx; /* Extract file Ids of files from directory */ vl_NbFilesToGet = mFm80_04ReadEntrysOfDirFile ( vl_Which, vl_NbFilesToGet, pl_DirCtx, pl_IdTab, sizeof (u16) * MFM_ID_TAB_SIZE, pl_ReadBuff, MFM_SIZE_OF_READ_BUFF, pl_Param->p_Status ); /* If error or end of file exit loop */ if (( *pl_Param->p_Status != FS_OK ) || ( vl_NbFilesToGet == 0 ) ) break; MC_MFM_LL_GET_FILES_ADDR( vl_NbFilesToGet, pl_IdTab, pl_CurrentFileAddr, vl_DestBuffSize, &vl_NbFilesGot, &pl_OutFileAddr, &vl_UsedBufferSize, pl_Param->p_Status ); /* If number of files received less than number of files got than buffer is full set exit flag */ if ( vl_NbFilesGot < vl_NbFilesToGet ) { vl_ExitReq = TRUE; /* As all addresses of files would not placed in destination addr buffer the directory pointer points after the nomal position */ /* Restore directory context */ * pl_DirCtx = sl_DirCtx; /* Update directory context by reading entrys of dir file */ vl_NbFilesToGet = mFm80_04ReadEntrysOfDirFile ( vl_Which, vl_NbFilesGot, pl_DirCtx, pl_IdTab, sizeof (u16) * MFM_ID_TAB_SIZE, pl_ReadBuff, MFM_SIZE_OF_READ_BUFF, pl_Param->p_Status ); } /* If error exit loop */ if ( *pl_Param->p_Status != FS_OK ) break; /* If number of files got null than buffer can be full */ if ( vl_NbFilesGot == 0 ) { /* If no one file got buffer too small to receive a sigle entry set an error and exit loop */ if ( vl_TotalNbFilesGot == 0 ) { *pl_Param->p_Status = FS_ERANGE; break; } else vl_ExitReq = TRUE; } else { /* If number of files received less than number of files got than buffer is full set exit flag */ if ( vl_NbFilesGot < vl_NbFilesToGet ) vl_ExitReq = TRUE; /* Update number total of files got */ vl_TotalNbFilesGot += vl_NbFilesGot; /* Updates current pointer in addr buffer */ pl_CurrentFileAddr = (t_fssFileAddr *)( ((u8*) pl_CurrentFileAddr) + vl_UsedBufferSize); /* Updates available dest addr buffer size */ vl_DestBuffSize -= vl_UsedBufferSize; } /* Updates which position to next */ vl_Which.v_Position = FS_NEXT_ELEM; } /* Update number of files got in input parameters */ if ( * pl_Param->p_Status != FS_OK ) * pl_Param->p_NumbOfFiles = 0; else * pl_Param->p_NumbOfFiles = vl_TotalNbFilesGot; /* Free memory allocated for Id table */ MC_MFM_FREE_MEMORY( pl_IdTab ); /* Free memory allocated for read buffer */ MC_MFM_FREE_MEMORY( pl_ReadBuff ); }}#endif /* FSS_FTR */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -