>+ PRUint32 i = 2;
>+ nsAutoString newFolderNameUnderTrash(folderName);
>+ while (1) {
>+ rv = CheckIfFolderExists(newFolderNameUnderTrash, this, NULL);
>+ if (rv == NS_MSG_FOLDER_EXISTS) {
>+ newFolderNameUnderTrash.Assign(folderName);
>+ newFolderNameUnderTrash.AppendLiteral("-"); // do we want this localizable? "<folder>-<SeqNo>"
>+ newFolderNameUnderTrash.AppendInt(i);
>+ i++;
>+ } else if (NS_SUCCEEDED(rv)) {
>+ // NS_OK so the tried folder name doesn't exist
>+ break;
>+ } else {
>+ return rv;
>+ }
>+ }
CheckIfFolderExists is overkill if you don't want to alert, use ContainsChildNamed instead. Also, the loop is horribly written, though maybe you might think my version is going too far the other way:
bool containsChild;
for (int32_t i = 2; ContainsChildNamed(destFolderName, &containsChild), containsChild; i++) {
// compute new folder name
}
Comment on attachment 8370331
WIP patch 2
>+ PRUint32 i = 2; derTrash( folderName) ; ists(newFolderN ameUnderTrash, this, NULL); FOLDER_ EXISTS) { derTrash. Assign( folderName) ; derTrash. AppendLiteral( "-"); // do we want this localizable? "<folder>-<SeqNo>" derTrash. AppendInt( i); med(destFolderN ame, &containsChild), containsChild; i++) {
>+ nsAutoString newFolderNameUn
>+ while (1) {
>+ rv = CheckIfFolderEx
>+ if (rv == NS_MSG_
>+ newFolderNameUn
>+ newFolderNameUn
>+ newFolderNameUn
>+ i++;
>+ } else if (NS_SUCCEEDED(rv)) {
>+ // NS_OK so the tried folder name doesn't exist
>+ break;
>+ } else {
>+ return rv;
>+ }
>+ }
CheckIfFolderExists is overkill if you don't want to alert, use ContainsChildNamed instead. Also, the loop is horribly written, though maybe you might think my version is going too far the other way:
bool containsChild;
for (int32_t i = 2; ContainsChildNa
// compute new folder name
}