parentDir->CreateNewDirectory(fileString.GetUnicode(), fileName, mMigrating);
parentDir->CreateDirectoryByURI(fileString.GetUnicode(), mDbUri, mMigrating);
nsresult AddressBookParser::ParseFile(){	/* Get database file name */	char *leafName = nsnull;	nsAutoString fileString;	if (mFileSpec) {		mFileSpec->GetLeafName(&leafName);		fileString.AssignWithConversion(leafName);		// todo:  detect ldif / tab files a better way		if (-1 != fileString.Find(kTabExtension) || -1 != fileString.Find(kTxtExtension))			mFileType = TABFile;		else if (-1 != fileString.Find(kLdifExtension))			mFileType = LDIFFile;		else			return NS_ERROR_FAILURE;		PRInt32 i = 0;		while (leafName[i] != '\0')		{			if (leafName[i] == '.')			{				leafName[i] = '\0';				break;			}			else				i++;		}		if (leafName)			mDbUri = PR_smprintf("%s%s.mab", kDirectoryDataSourceRoot, leafName);	}	nsresult rv = NS_OK;	nsFileSpec* dbPath = nsnull;	char* fileName = PR_smprintf("%s.mab", leafName);	NS_WITH_SERVICE(nsIAddrBookSession, abSession, kAddrBookSessionCID, &rv); 	if(NS_SUCCEEDED(rv))		abSession->GetUserProfileDirectory(&dbPath);		/* create address book database  */	if (dbPath)	{		(*dbPath) += fileName;		NS_WITH_SERVICE(nsIAddrDatabase, addrDBFactory, kAddressBookDBCID, &rv);		if (NS_SUCCEEDED(rv) && addrDBFactory)			rv = addrDBFactory->Open(dbPath, PR_TRUE, getter_AddRefs(mDatabase), PR_TRUE);	}	if (NS_FAILED(rv))        return NS_ERROR_FAILURE;    NS_WITH_SERVICE(nsIRDFService, rdfService, kRDFServiceCID, &rv);	if(NS_FAILED(rv))		return rv;	nsCOMPtr<nsIRDFResource> parentResource;	char *parentUri = PR_smprintf("%s", kDirectoryDataSourceRoot);	rv = rdfService->GetResource(parentUri, getter_AddRefs(parentResource));	nsCOMPtr<nsIAbDirectory> parentDir = do_QueryInterface(parentResource);	if (!parentDir)		return NS_ERROR_NULL_POINTER;	if (parentUri)		PR_smprintf_free(parentUri);	if (PL_strcmp(fileName, kPersonalAddressbook) == 0)	{		// This is the personal address book, get name from prefs		NS_WITH_SERVICE(nsIPref, pPref, kPrefCID, &rv); 		if (NS_FAILED(rv) || !pPref) 			return nsnull;		PRUnichar *dirName = nsnull;		rv = pPref->GetLocalizedUnicharPref("ldap_2.servers.pab.description", &dirName);		parentDir->CreateNewDirectory(dirName, fileName, mMigrating);		nsMemory::Free(dirName);	}	else		parentDir->CreateNewDirectory(fileString.GetUnicode(), fileName, mMigrating);    // Initialize the parser for a run...    mLine.Truncate();	if (mFileType == TABFile)		rv = ParseTabFile();	else if (mFileType == LDIFFile)		rv = ParseLDIFFile();	else 		rv = NS_ERROR_FAILURE;	if(NS_FAILED(rv))		return rv;	if (leafName)		nsCRT::free(leafName);	if (fileName)		PR_smprintf_free(fileName);   return NS_OK;}