For Programmers: Free Programming Magazines  


Home > Archive > Unix Programming > June 2006 > Re: an argument in stat









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: an argument in stat
lszk

2006-06-19, 4:01 am

It works:

struct stat info;
// map<string, int> pliki;
char path[PATH_MAX + 1];
size_t path_len;
path_len = strlen(katalog);
strncpy(path, katalog, sizeof(path));
if(path[path_len - 1] != '/'){
path[path_len] = '/';
path[path_len + 1] = '\0';
++path_len;
}
kat = opendir(katalog);
while(wynik = readdir(kat)){
strncpy(path + path_len, wynik->d_name, sizeof(path) - path_len);
stat(path, &info);
if(S_ISREG(info.st_mode)){
cout << "plik" << " " << wynik->d_name << endl;
// pliki[wynik->d_name] = info.st_ctime;
}
else cout << "katalog" << " " << wynik->d_name << endl;
}

Thx for all.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com