int Simulator::handleConfiguration() { // handle config file int handle = handleConfigFile(handleSlash((flags[0]).c_str()), config); if (handle < 0) { if (handle == -2) { cout << USAGE << endl; cout << ERROR_FIND_CONFIG_FILE << fullPath(handleSlash((flags[0]).c_str())) << endl; } return -1; } return 0; }
int main(int argc, char *argv[]) #endif { DIR *d; struct dirent *de; struct stat sb; argv0 = argv[0]; if (argc != 2) { fprintf(stderr, "usage: %s: <configdir|configfile>\n", argv0); exit(EXIT_FAILURE); } stat(argv[1], &sb); if (S_ISREG(sb.st_mode)) { handleConfigFile(argv[1]); exit(EXIT_SUCCESS); } if ((d = opendir(argv[1])) == NULL) { fprintf(stderr, "%s: opendir() failed to open the directory\n", argv0); exit(EXIT_FAILURE); } while ((de = readdir(d)) != NULL) { if ((de->d_name[0] != '.')) { char *foo; if (asprintf(&foo, "%s/%s", argv[1], de->d_name)) handleConfigFile(foo); free(foo); } } exit(EXIT_SUCCESS); }