child->SetFlags(flags);
nsFolderCompactState::FinishCompact(){    // All okay time to finish up the compact process  nsresult rv = NS_OK;  nsCOMPtr<nsIFileSpec> pathSpec;  nsCOMPtr<nsIFolder> parent;  nsCOMPtr<nsIMsgFolder> parentFolder;  nsCOMPtr<nsIDBFolderInfo> folderInfo;  nsFileSpec fileSpec;    // get leaf name and database name of the folder  rv = m_folder->GetPath(getter_AddRefs(pathSpec));  pathSpec->GetFileSpec(&fileSpec);  nsLocalFolderSummarySpec summarySpec(fileSpec);  nsXPIDLCString idlName;  nsString dbName;  pathSpec->GetLeafName(getter_Copies(idlName));  summarySpec.GetLeafName(dbName);    // close down the temp file stream; preparing for deleting the old folder    // and its database; then rename the temp folder and database  m_fileStream->flush();  m_fileStream->close();  delete m_fileStream;  m_fileStream = nsnull;    // make sure the new database is valid  m_db->SetSummaryValid(PR_TRUE);  m_db->Commit(nsMsgDBCommitType::kLargeCommit);  m_db->ForceClosed();  m_db = null_nsCOMPtr();  nsLocalFolderSummarySpec newSummarySpec(m_fileSpec);    // close down database of the original folder and remove the folder node    // and all it's message node from the tree  m_folder->ForceDBClosed();  m_folder->GetParent(getter_AddRefs(parent));  parentFolder = do_QueryInterface(parent, &rv);  m_folder->SetParent(nsnull);  parentFolder->PropagateDelete(m_folder, PR_FALSE);    // remove the old folder and database  fileSpec.Delete(PR_FALSE);  summarySpec.Delete(PR_FALSE);    // rename the copied folder and database to be the original folder and    // database   m_fileSpec.Rename((const char*) idlName);  newSummarySpec.Rename(dbName);    // add the node back the tree  nsCOMPtr<nsIMsgFolder> child;  nsAutoString folderName; folderName.AssignWithConversion((const char*) idlName);  rv = parentFolder->AddSubfolder(&folderName, getter_AddRefs(child));  if (child)   {    nsCOMPtr<nsISupports> childSupports = do_QueryInterface(child);    nsCOMPtr<nsISupports> parentSupports = do_QueryInterface(parentFolder);    if (childSupports && parentSupports)    {      parentFolder->NotifyItemAdded(parentSupports, childSupports,                                    "folderView");    }  }  return rv;}