Comment 123 for bug 214366

Revision history for this message
In , UlfZibis (ulf-zibis) wrote :

Little sophisticated:

>+ newFolderName.Assign(folderName);
>+ for (uint32_t i=2, containsChild; ; i++) {
>+ rv = ContainsChildNamed(newFolderName, &containsChild);
>+ NS_ENSURE_SUCCESS(rv, rv);
>+ if (!containsChild)
>+ break;
>+ // This could be localizable but Toolkit is fine without it, see
>+ // mozilla/toolkit/content/contentAreaUtils.js::uniqueFile()
>+ newFolderName.Assign(folderName);
>+ newFolderName.AppendLiteral("(");
>+ newFolderName.AppendInt(i);
>+ newFolderName.AppendLiteral(")");
>+ }

Or really type clean:
>+ for (uint32_t i=2; ; i++) {
>+ bool containsChild;
>+ rv = ContainsChildNamed(newFolderName, &containsChild);
...

I'm not sure, if newFolderName and rv also could be drawn into the loop, are they used outside?