SHARE
TWEET

dsajdkasnkdas

a guest Apr 19th, 2019 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <dirent.h>
  3. #include <string.h>
  4.  
  5. void listDir(const char *cale, const char *fisierCautat)
  6. {
  7.     DIR *dir;
  8.     struct dirent *fisier;
  9.    
  10.    if (!(dir = opendir(cale))) {
  11.         return;
  12.     }
  13.  
  14.     while ((fisier = readdir(dir)) != NULL) {
  15.         if (fisier->d_type == DT_DIR) {
  16.             char path[1024];
  17.             if (strcmp(fisier->d_name, ".") == 0 || strcmp(fisier->d_name, "..") == 0)
  18.                 continue;
  19.             snprintf(path, sizeof(path), "%s/%s", cale, fisier->d_name);
  20.             listDir(path, fisierCautat);
  21.         }else if(strcmp(fisier->d_name, fisierCautat) == 0) {
  22.             printf("%s/%s\n",cale, fisier->d_name);
  23.         }
  24.     }
  25.     closedir(dir);
  26. }
  27.  
  28. int main(int argc, char* v[]) {
  29.     const char* homedir = "/home";
  30.     printf("%s\n", homedir);
  31.     listDir(homedir, v[1]);
  32.     return 0;
  33. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top