CPPGenerateListRecursively

void RecursivelyBuildListHtml(char* pszPath, FILE* pOutputFile, const char* pPrevName, int iDepth, int& ID, LookupList& lookupList)
{
char tmpPath[1024];
DIR* dp = opendir(pszPath);
dirent* dirp;

if (dp == nullptr)
return;

while ((dirp = readdir(dp)) != NULL)
{
if (dirp->d_type == DT_DIR || dirp->d_type == DT_REG)
{
if (dirp->d_type == DT_DIR && ShouldIgnoreDir(dirp->d_name))
continue;

if (dirp->d_type == DT_REG && ShouldIgnoreReg(dirp->d_name))
continue;

snprintf(tmpPath, sizeof(tmpPath), “%s/%s”, pszPath, dirp->d_name);

const char* displayType = iDepth >= 0 ? “display: none;” : “display: ;”;
const char* szName = dirp->d_type == DT_REG ? “name=\”file\”” : “”;

if (dirp->d_type == DT_REG)
lookupList[ID] = tmpPath;

fprintf(pOutputFile, “

  • ” “” “\n”, szName, std::to_string(ID++).c_str(), dirp->d_name);
    if (dirp->d_type == DT_DIR)
    {
    fprintf(pOutputFile, “

      \n”, displayType);
      RecursivelyBuildListHtml(tmpPath, pOutputFile, dirp->d_name, iDepth + 1, ID, lookupList);
      fprintf(pOutputFile, “

    \n”);
    }
    fprintf(pOutputFile, “

  • \n”);
    }
    }
    }