你可以参考一下这部分的代码:
//
// Initialize the file system tree pointer to the root of the linked list.
//
ptTree = FS_ROOT;
//
// Begin processing the linked list, looking for the requested file name.
//
while(NULL != ptTree)
{
//
// Compare the requested file "name" to the file name in the
// current node.
//
if(strncmp(name, (char *)ptTree->name, ptTree->len) == 0)
{
//
// Fill in the data pointer and length values from the
// linked list node.
//
ptFile->data = (char *)ptTree->data;
ptFile->len = ptTree->len;
//
// For now, we setup the read index to the end of the file,
// indicating that all data has been read.
//
ptFile->index = ptTree->len;
//
// We are not using any file system extensions in this
// application, so set the pointer to NULL.
//
ptFile->pextension = NULL;
//
// Exit the loop and return the file system pointer.
//
break;
}
//
// If we get here, we did not find the file at this node of the linked
// list. Get the next element in the list.
//
ptTree = ptTree->next;
} |