Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void ListDir(char *dir, DIR *dp, struct dirent *ep,bool recursive, int indent){
- DIR *tdp;
- struct dirent *tep;
- char tmpDir[256];
- if (dir[strlen(dir)-1] != '/') strcat(dir,"/");
- dp = opendir(dir);
- if (dp != NULL){
- while (ep = readdir(dp)){
- strcpy(tmpDir,dir);
- strcpy(tmpDir,strcat(tmpDir,ep->d_name));
- for(int i=0; i<indent; i++) cout << '-';
- tdp = opendir(tmpDir);
- if (tdp != NULL){
- closedir(tdp);
- if (recursive) ListDir(tmpDir,tdp,tep,recursive,indent);
- }
- //else ReadFile();
- if(ep->d_name != "." && ep->d_name != "..")cout << ep->d_name << endl;
- tmpDir[0] = '\0';//ClearStr(tmpDir);
- }
- closedir(dp);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment