리눅스에서의 디렉토리 순회
2009/09/15 14:55
적절하게 수정 후 사용.
윤드림 횽의 조인시를 참고하였음.
윤드림 횽의 조인시를 참고하였음.
//Made By YuriHan.
void foo(std::string& inDir) { struct dirent *item; DIR *dp; struct stat stat;
dp = opendir(inDir.c_str());
if(dp!=NULL) { while(1) { item = readdir(dp); if (item == NULL) break;
lstat(item->d_name,&stat); if (S_ISDIR(stat.st_mode)) continue;
string name = item->d_name;
//doSomething.. } } closedir(dp); }


ftw(), nftw() 라는 아름다운 함수가 있습니다.
감사히 받아먹겠습니다.