/** * Scans the contents of the directory named *dirname, and allocates and fills in an * array of entries describing them in *filelist. The length of the array is the function result. */ unsigned int BLI_dir_contents(const char *dirname, struct direntry **filelist) { struct BuildDirCtx dir_ctx; dir_ctx.nrfiles = 0; dir_ctx.files = NULL; bli_builddir(&dir_ctx, dirname); bli_adddirstrings(&dir_ctx); if (dir_ctx.files) { *filelist = dir_ctx.files; } else { // keep blender happy. Blender stores this in a variable // where 0 has special meaning..... *filelist = malloc(sizeof(struct direntry)); } return dir_ctx.nrfiles; }
unsigned int BLI_dir_contents(const char *dirname, struct direntry **filelist) { // reset global variables // memory stored in files is free()'d in // filesel.c:freefilelist() actnum = totnum = 0; files = NULL; bli_builddir(dirname, ""); bli_adddirstrings(); if (files) { *(filelist) = files; } else { // keep blender happy. Blender stores this in a variable // where 0 has special meaning..... *(filelist) = files = malloc(sizeof(struct direntry)); } return(actnum); }