//用孩子兄弟表示法的结构来存储文件目录 //用先序查找 typedef struct CSNode { char data[2048]; struct CSNode *firstchild, *nextsibling , *parent; }CSNode; // 版权所有 (C)2007, ***(成都)有限公司。 // // 描述: // 解析文件目录树 //树是一种常用的数据结构,如文件目录结构就是一种树形结构。现给定一个目录路径(如:C:/Data/), //请实现一个目录结构树,并将其子目录和子文件打印出来,具体效果如windows命令tree。 //要求: //1、先遍历目录,将目录树保存到内存 //2、实现一个打印输出函数,将保存的目录树打印输出 // 作者:陈进宇 chenjinyu_china@yeah.net #include <iostream> #include <string.h> #include <afx.h> #include <cwchar> #include "TreeNode.h" #define MAX_LEN 1024 using namespace std; struct CSNode *GetFiles(char *strPath,struct CSNode *treeN);//递归查找文件和文档 struct CSNode *InsertSibling(struct CSNode *pRoot,struct CSNode *pParent,char *filename);//是兄弟 struct CSNode *InsertChild(struct CSNode *pRoot,char *filename);//是孩子 struct CSNode *CreateTree(struct CSNode *node);//创建树节点 void PrintTree(struct CSNode *node,int nLevel); void Del