Увидели сообщение с непонятной ссылкой, спам, непристойность или оскорбление?Воспользуйтесь ссылкой «Сообщить модератору» рядом с сообщением!
0 Пользователей и 1 Гость просматривают эту тему.
// find// test_find.c// victor00000 (c) 2018.#define _GNU_SOURCE#include <stdio.h>#include <dirent.h>#include <sys/types.h>#include <sys/stat.h>#include <unistd.h>#include <stdlib.h>// ~$ gcc -Wall test_find.c -o test_find// ~$ ./test_find /etc 1 2 3void find_l ( const char *p ){DIR *d = 0;d = opendir ( p );if ( d == 0 ){perror ( p );return;}struct dirent *e;char *c = 0;while ((e = readdir ( d )) != 0 ){if (e->d_type == 4){if (e->d_name[0] == '.' ){if (e->d_name[1] == 0) continue;if (e->d_name[1] == '.' )if (e->d_name[2] == 0) continue;}}if ( p[0] == '/' && p[1] == 0 )asprintf (&c,"%s%s",p,e->d_name);elseasprintf (&c,"%s/%s",p,e->d_name);printf ("%s\n",c);if ( e->d_type == 4 ){find_l ( c );}free (c);fflush ( stdout );}}int main (int ia, char *ca[]){if (ia == 1) return 0;int i;struct stat ls;for (i=1;i<ia;i++){if (!opendir (ca[i])){if (lstat(ca[i],&ls) == 0){printf ("%s\n",ca[i]);continue;}else{perror (ca[i]);continue;}}printf ("%s\n",ca[i]);find_l (ca[i]);}return 0;}
fflush ( stdout );}}
fflush ( stdout );}closedir (d);}
Страница сгенерирована за 0.043 секунд. Запросов: 25.