The code looks like so:
Code:
#include <stdio.h>
#include <unistd.h>
#include <dirent.h>
int processIt(const char* command, char* paths[])
{
printf("processIt\n");
int status;
int i;
DIR *dir;
struct dirent *entry;
int x;
for (i = 0; paths[i] != NULL; i++) {
printf("Search path before loop: %s\n", paths[i]);
dir = opendir(paths[i]);
if (dir == NULL) {
printf("Error");
return -1;
}
while ((entry = readdir(dir)) != NULL) {
printf("Found a file.\n");
printf("file:%s\n", entry->d_name);
}
closedir(dir);
}
return 0;
} /* processIt! */
int main(int argc, char *argv[])
{
char *paths[] = {"DayDate", "Documents", "Library", 0};
processIt("ls", paths);
return 0;
}
Obviously, those are just three directories I happened to choose out of my home directory. I took out some of the variables that weren't being used, too.