📄 fs23rename.c
字号:
#ifdef FSS_FTR#define ACCESS_RIGHTS_INTERNAL_FS#define FS23RENAME_C#undef FILE_NUMBER#define FILE_NUMBER 23 #include "Fs.h"#undef PROCEDURE_NUMBER #define PROCEDURE_NUMBER 1void Fs23_01Rename ( void * pp_Param ){ t_ObjectInfo sl_OldInfo, sl_NewInfo; fsPath * pl_RestOfPathOld; fsPath * pl_RestOfPathNew; t_fsVolStruct * pl_VolumeOld; t_fsVolStruct * pl_VolumeNew; t_fsEntityStruct * pl_FsEntityPtr = 0; /* Pointer on entity's CB */ t_FssCmdRename * pl_Param = (t_FssCmdRename *) pp_Param; /* Treat volumes of 2 paths ( both must exist and be identical ) */ /* --------------------------------------------------------------*/ /* Get entity's context pointer if one of the paths need the entity's current directory */ if ( ( *((fsPath*) pl_Param->p_OldName) != '/') || (*((fsPath*)pl_Param->p_NewName) != '/' )) pl_FsEntityPtr = MC_FS_ED_GET_ENTITY_PTR( MC_FS_KERNEL_ID(pl_Param) ); /* For old path get volume of object */ pl_VolumeOld = MC_FS_CO_GIVE_VOLUME_FROM_PATH ( pl_FsEntityPtr, (fsPath*)pl_Param->p_OldName, &pl_RestOfPathOld, &sl_OldInfo, &MC_FS_STATUS(pl_Param) ); /* If no volume return */ if ( pl_VolumeOld == NIL ) return; /* For old path get volume of object */ pl_VolumeNew = MC_FS_CO_GIVE_VOLUME_FROM_PATH ( pl_FsEntityPtr, (fsPath*)pl_Param->p_NewName, &pl_RestOfPathNew, &sl_NewInfo, &MC_FS_STATUS(pl_Param) ); /* If no volume return */ if ( pl_VolumeNew == NIL ) return; /* If volumes are not identical return */ if ( pl_VolumeNew != pl_VolumeOld ) { /* Volumes not identical-> error */ MC_FS_STATUS(pl_Param) = FS_EXDEV; return; } /* Set the interlayer table pointer */ MC_FS_LL_SET_NEW_VOL(pl_VolumeNew); /* Verify if object to rename exist */ /*--------------------------------*/ /* Take info on object ( dir exist, object exist, ...) at lower layer */ MC_FS_LL_GET_OBJECT_INFO (&sl_OldInfo, pl_RestOfPathOld, &MC_FS_STATUS(pl_Param)); /* If an error in info get return */ if ( MC_FS_STATUS(pl_Param) != FS_OK ) return; /* This object exist ? */ if ( sl_OldInfo.s_FileStatus.v_ObjExist ) { /* If directory do not exist a rename is not possible because it is not possible to rename the volume name */ if ( sl_OldInfo.s_FileStatus.v_DirExist == FALSE) { /* Err unknow destination directory */ MC_FS_STATUS(pl_Param) = FS_ENOENT; return; } } /* Object do not exist return err */ else { /* Err unknow file */ MC_FS_STATUS(pl_Param) = FS_ENOENT; return ; } /* Verify if new path ok ( all directories of path exist but file do not exist ) */ /*-------------------------------------------------------------------------------*/ /* Take info on object ( dir exist, object exist, ...) at FM */ MC_FS_LL_GET_OBJECT_INFO (&sl_NewInfo, pl_RestOfPathNew, &MC_FS_STATUS(pl_Param)); /* If an error in info get return */ if ( MC_FS_STATUS(pl_Param) != FS_OK ) return; /* If destination directory do not exist a rename is not possible because it is not possible to rename the volume name */ if ( sl_NewInfo.s_FileStatus.v_DirExist == FALSE ) { /* Err unknow destination directory */ MC_FS_STATUS(pl_Param) = FS_ENOENT; return; } /* If new file name exist already a rename is not possible */ if ( sl_NewInfo.s_FileStatus.v_ObjExist ) { /* Is the new object the same that the old then nothing to do return */ if ( sl_NewInfo.v_ObjID == sl_OldInfo.v_ObjID ) return; /* else err file exist */ MC_FS_STATUS(pl_Param) = FS_EEXIST; return; } /* Ask FM to rename file */ MC_FS_LL_RENAME( &sl_OldInfo, pl_RestOfPathOld, &sl_NewInfo, pl_RestOfPathNew, &MC_FS_STATUS(pl_Param) );}#undef PROCEDURE_NUMBER #define PROCEDURE_NUMBER 2u32 Fs23_02ProcessRename( u8 vp_Behaviour, const fsPath * pp_OldName, const fsPath * pp_NewName){ /* Reserve message space */ t_FsCmdRename * pl_Rename = ( t_FsCmdRename * ) MC_FS_GET_MEMORY(sizeof(t_FsCmdRename)); /* Fill message with input parameters */ pl_Rename->p_OldName = pp_OldName; pl_Rename->p_NewName = pp_NewName; /* Send message by setting operation and return command identifier */ return( MC_FS_MA_SEND_CMD_MSG_TO_FS(vp_Behaviour, (void*)pl_Rename,FS_CMD_RENAME_REQ));}#endif /* FSS_FTR */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -