equal
deleted
inserted
replaced
46 perror (root); |
46 perror (root); |
47 return; |
47 return; |
48 } |
48 } |
49 |
49 |
50 while ((entry = readdir (directory))) { |
50 while ((entry = readdir (directory))) { |
51 list = (char *)malloc (strlen (root) + 1 + strlen (entry->d_name) + 1); |
51 if ((!strcmp (entry->d_name, ".")) || (!strcmp (entry->d_name, ".."))) |
|
52 continue; |
52 |
53 |
53 if (list == NULL) { |
54 list = malloc (strlen (root) + 1 + strlen (entry->d_name) + 1); |
54 perror ("malloc"); |
|
55 return; |
|
56 } |
|
57 |
|
58 sprintf (list, "%s/%s", root, entry->d_name); |
55 sprintf (list, "%s/%s", root, entry->d_name); |
59 |
56 |
60 if (!strcmp (entry->d_name, ".")) |
|
61 continue; |
|
62 if (!strcmp (entry->d_name, "..")) |
|
63 continue; |
|
64 if (isDir (list)) { |
57 if (isDir (list)) { |
65 printf ("Directory: %s\n", list); |
58 printf ("Directory: %s\n", list); |
66 if (recursive) |
59 if (recursive) |
67 getdir (list, recursive); |
60 getdir (list, recursive); |
|
61 free (list); |
68 continue; |
62 continue; |
69 } |
63 } |
70 |
64 |
71 printf ("%s\n", list); |
65 printf ("%s\n", list); |
|
66 free (list); |
72 } |
67 } |
73 |
68 |
74 free (list); |
|
75 closedir (directory); |
69 closedir (directory); |
76 } |
70 } |