......................................
struct dirent *entry;
DIR *dir;
struct stat st;
dir = opendir(path.c_str());
while ( (entry = readdir (dir)) != NULL)
{
const char * type;
std::string tmp( entry->d_name);
// if ( (tmp == ".") || (tmp == ".."))
// continue;
stat (path.c_str(), &st);
if ( S_ISREG (st.st_mode))
std::cout << "\n\tfile=" << tmp << "\tsize=" << st.st_size << std::endl;
if ( S_ISDIR (st.st_mode))
std::cout << "\n\tdir=" << tmp << "\tsize=" << st.st_size << std::endl;
};
closedir(dir);
.....................................................
stalcker@stalcker:/work/vacancy$ ./out ./1/ ./2/
dir=. size=1024
dir=.. size=1024
dir=1_2 size=1024
dir=1_1 size=1024
dir=main.cpp size=1024
dir=. size=1024
dir=.. size=1024
dir=2_1 size=1024
dir=2_2 size=1024
dir=main.d size=1024
При чтении каталогов, файлы в них определяются не как файлы,
а как каталоги. Помогите разобраться.
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.
Похожие темы
- Форум Ошибка сегментирования. Рекурсивный обход каталогов (2017)
- Форум Не работает велосипед pwd на сях (2015)
- Форум stat и lstat в Solaris - есть ли? (2008)