/* Returns number of files successfully read; negative number if error */ int pl_file_get_file_list(pl_file_list *list, const char *path, const char **filter) { SceUID fd = sceIoDopen(path); if (fd < 0) return -1; SceIoDirent dir; memset(&dir, 0, sizeof(dir)); pl_file *file, *last = NULL; list->files = NULL; const char **pext; int loop; int count = 0; while (sceIoDread(fd, &dir) > 0) { if (filter && !(SCE_S_ISDIR(dir.d_stat.st_mode))) { /* Loop through the list of allowed extensions and compare */ for (pext = filter, loop = 1; *pext; pext++) { if (pl_file_is_of_type(dir.d_name, *pext)) { loop = 0; break; } } if (loop) continue; } /* Create a new file entry */ if (!(file = (pl_file*)malloc(sizeof(pl_file)))) { pl_file_destroy_file_list(list); return -1; } file->name = strdup(dir.d_name); file->next = NULL; file->attrs = (SCE_S_ISDIR(dir.d_stat.st_mode)) ? PL_FILE_DIRECTORY : 0; /* Update preceding element */ if (last) last->next = file; else list->files = file; last = file; count++; } sceIoDclose(fd); /* Sort the files by name */ sort_file_list(list, count); return count; }
int main(int argc, char *argv[]) { const char *dirname; int listnum; int result; /* first argument is the directory */ if (argc < 3) { fprintf(stderr, "Usage:\nsummcomp <outputdir> <summary1> [<summary2> [<summary3> ...]]\n"); return 1; } dirname = argv[1]; list_count = argc - 2; /* loop over arguments and read the files */ for (listnum = 0; listnum < list_count; listnum++) { result = read_summary_log(argv[listnum + 2], listnum); if (result != 0) return result; } /* output the summary */ output_report(dirname, sort_file_list()); return 0; }
int main(int argc, char *argv[]) { astring *dirname = NULL, *tempfilename = NULL, *tempheader = NULL, *tempfooter = NULL; UINT32 bufsize; void *buffer; int listnum; int result; /* first argument is the directory */ if (argc < 4) { fprintf(stderr, "Usage:\nregrep <template> <outputdir> <summary1> [<summary2> [<summary3> ...]]\n"); return 1; } tempfilename = astring_dupc(argv[1]); dirname = astring_dupc(argv[2]); list_count = argc - 3; /* read the template file into an astring */ if (core_fload(astring_c(tempfilename), &buffer, &bufsize) == FILERR_NONE) { tempheader = astring_dupch((const char *)buffer, bufsize); free(buffer); } /* verify the template */ if (tempheader == NULL) { fprintf(stderr, "Unable to read template file\n"); return 1; } result = astring_findc(tempheader, 0, "<!--CONTENT-->"); if (result == -1) { fprintf(stderr, "Template is missing a <!--CONTENT--> marker\n"); return 1; } tempfooter = astring_substr(astring_dup(tempheader), result + 14, -1); tempheader = astring_substr(tempheader, 0, result); /* loop over arguments and read the files */ for (listnum = 0; listnum < list_count; listnum++) { result = read_summary_log(argv[listnum + 3], listnum); if (result != 0) return result; } /* output the summary */ output_report(dirname, tempheader, tempfooter, sort_file_list()); astring_free(dirname); astring_free(tempfilename); astring_free(tempheader); astring_free(tempfooter); return 0; }
int main(int argc, char *argv[]) { UINT32 bufsize; void *buffer; int listnum; int result; /* first argument is the directory */ if (argc < 4) { fprintf(stderr, "Usage:\nregrep <template> <outputdir> <summary1> [<summary2> [<summary3> ...]]\n"); return 1; } std::string tempfilename(argv[1]); std::string dirname(argv[2]); list_count = argc - 3; /* read the template file into an astring */ std::string tempheader; if (util::core_file::load(tempfilename.c_str(), &buffer, bufsize) == osd_file::error::NONE) { tempheader.assign((const char *)buffer, bufsize); osd_free(buffer); } /* verify the template */ if (tempheader.length() == 0) { fprintf(stderr, "Unable to read template file\n"); return 1; } result = tempheader.find("<!--CONTENT-->"); if (result == -1) { fprintf(stderr, "Template is missing a <!--CONTENT--> marker\n"); return 1; } std::string tempfooter(tempheader); tempfooter = tempfooter.substr(result + 14); tempfooter = tempheader.substr(0, result); /* loop over arguments and read the files */ for (listnum = 0; listnum < list_count; listnum++) { result = read_summary_log(argv[listnum + 3], listnum); if (result != 0) return result; } /* output the summary */ output_report(dirname, tempheader, tempfooter, sort_file_list()); return 0; }