Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main(int argc, char *argv[])
- {
- char PathName [256] = "/home/ubermarginal/proces";
- pid_t id;
- DIR *dir;
- dirent *dirName;
- struct stat bufStat;
- dir = opendir(PathName);
- while ( (dirName = readdir(dir) )!=NULL )
- {
- char PathNamebuf[256]="";
- strcpy(PathNamebuf,PathName);
- std::cout << dirName->d_name << std::endl;
- strcat(PathNamebuf,"/");
- strcat(PathNamebuf,dirName->d_name);
- int statError = stat(PathNamebuf,&bufStat);
- std::cout << PathNamebuf << std::endl;
- if (statError == 0)
- {
- if ( (S_ISDIR(bufStat.st_mode)!=0) && ((strcmp(dirName->d_name,".") ) &&(strcmp(dirName->d_name,"..") ) ) )
- {
- id = fork();
- switch (id) {
- case -1:
- std::cout << "Error" << std::endl;
- break;
- case 0:
- closedir(dir);
- std::cout << PathName << std::endl;
- dir = opendir(PathName);
- break;
- default:
- break;
- }
- }
- }
- }
- closedir(dir);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement