本文整理汇总了C++中nsString::AppendPrintf方法的典型用法代码示例。如果您正苦于以下问题:C++ nsString::AppendPrintf方法的具体用法?C++ nsString::AppendPrintf怎么用?C++ nsString::AppendPrintf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsString
的用法示例。
在下文中一共展示了nsString::AppendPrintf方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ListInterestingFiles
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);
}
}
}