//for linux
- void findAllFile(char * pFilePath){
- DIR * dir;
- dirent * ptr;
- struct stat stStatBuf;
- chdir(pFilePath);
- dir = opendir(pFilePath);
- while ((ptr = readdir(dir)) != NULL){
- if (stat(ptr->d_name, &stStatBuf) == -1){
- printf("Get the stat error on file:%s\n", ptr->d_name);
- continue;
- }
- if ((stStatBuf.st_mode & S_IFDIR) && strcmp(ptr->d_name, ".") != 0&& strcmp(ptr->d_name, "..") != 0){
- char Path[MAX_PATH];
- strcpy(Path, pFilePath);
- strncat(Path, "/", 1);
- strcat(Path, ptr->d_name);
- findAllFile(Path);
- }
- if (stStatBuf.st_mode & S_IFREG){
- printf(" %s\n", ptr->d_name);
- }
- //this must change the directory , for maybe changed in the recured function
- chdir(pFilePath);
- }
- closedir(dir);
- }