static void ListInterestingFiles(nsString& aAnnotation, nsIFile* aFile, const nsTArray<nsString>& aInterestingFilenames) { nsString filename; aFile->GetLeafName(filename); for (const nsString& interestingFilename : aInterestingFilenames) { if (interestingFilename == filename) { nsString path; aFile->GetPath(path); aAnnotation.AppendLiteral(" "); aAnnotation.Append(path); aAnnotation.AppendLiteral(" ("); int64_t size; if (NS_SUCCEEDED(aFile->GetFileSize(&size))) { aAnnotation.AppendPrintf("%ld", size); } else { aAnnotation.AppendLiteral("???"); } aAnnotation.AppendLiteral(" bytes, crc32 = "); uint32_t crc; nsresult rv = ComputeCRC32(aFile, &crc); if (NS_SUCCEEDED(rv)) { aAnnotation.AppendPrintf("0x%08x)\n", crc); } else { aAnnotation.AppendPrintf("error 0x%08x)\n", uint32_t(rv)); } return; } } bool isDir = false; aFile->IsDirectory(&isDir); if (!isDir) { return; } nsCOMPtr<nsISimpleEnumerator> entries; if (NS_FAILED(aFile->GetDirectoryEntries(getter_AddRefs(entries)))) { aAnnotation.AppendLiteral(" (failed to enumerated directory)\n"); return; } for (;;) { bool hasMore = false; if (NS_FAILED(entries->HasMoreElements(&hasMore))) { aAnnotation.AppendLiteral(" (failed during directory enumeration)\n"); return; } if (!hasMore) { break; } nsCOMPtr<nsISupports> entry; if (NS_FAILED(entries->GetNext(getter_AddRefs(entry)))) { aAnnotation.AppendLiteral(" (failed during directory enumeration)\n"); return; } nsCOMPtr<nsIFile> file = do_QueryInterface(entry); if (file) { ListInterestingFiles(aAnnotation, file, aInterestingFilenames); } } }