/** * * @File : exo_06_2.cxx, Fichiers * * @Authors : A. B. Dragut * * @Date : 2011 * * @Synopsis : etude des fonctions pour les repertoires * opendir, readdir, chdir, closedir * **/ #include #include #include #include // struct stat #include #include #include "CExc.h" #include "nsSysteme.h" // LStat(), ChDir(), OpenDir(), ReadDir() using namespace nsSysteme; // LStat(), ChDir(), OpenDir(), ReadDir() using namespace std; int main (int argc, char * argv []) { try { if (2 != argc) throw CExc ("main()", string ("Usage : ") + argv [0] + " "); DIR *pDir(OpenDir(argv[1])); ChDir(argv[1]); dirent * pEntry; while((pEntry = ReadDir(pDir))) { struct stat S; LStat(pEntry -> d_name, & S); mode_t mode (S . st_mode); if(S_ISDIR(mode)) cout << "d"; else if(S_ISREG(mode)) cout << "-"; else if(S_IFLNK & mode) cout << "l"; else cout << "."; cout << ((S_IRUSR & mode)?"r":"-") << ((S_IWUSR & mode)?"w":"-") << ((S_IXUSR & mode)?"x":"-") << "\t" << S . st_size << "\t" << pEntry -> d_name << "\n"; } CloseDir(pDir); return 0; } catch (const CExc & Exc) { cerr <