NS_IMETHODIMP nsMailWinSearchHelper::GetFoldersInCrawlScope(bool* aResult) { *aResult = false; NS_ENSURE_ARG_POINTER(mProfD); // If the service isn't present or running, we shouldn't proceed. bool serviceRunning; nsresult rv = GetServiceRunning(&serviceRunning); if (!serviceRunning || NS_FAILED(rv)) return rv; // We need to do this every time so that we have the latest data nsRefPtr<ISearchManager> searchManager; HRESULT hr = CoCreateInstance(CLSID_CSearchManager, NULL, CLSCTX_ALL, IID_ISearchManager, getter_AddRefs(searchManager)); if (FAILED(hr)) return NS_ERROR_FAILURE; nsRefPtr<ISearchCatalogManager> catalogManager; hr = searchManager->GetCatalog(L"SystemIndex", getter_AddRefs(catalogManager)); if (FAILED(hr)) return NS_ERROR_FAILURE; nsRefPtr<ISearchCrawlScopeManager> crawlScopeManager; hr = catalogManager->GetCrawlScopeManager(getter_AddRefs(crawlScopeManager)); if (FAILED(hr)) return NS_ERROR_FAILURE; // We need to create appropriate URLs to check with the crawl scope manager. for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(sFoldersToIndex); i++) { nsCOMPtr<nsIFile> subdir; rv = mProfD->Clone(getter_AddRefs(subdir)); NS_ENSURE_SUCCESS(rv, rv); nsDependentCString relativeStr(sFoldersToIndex[i]); rv = subdir->AppendNative(relativeStr); NS_ENSURE_SUCCESS(rv, rv); nsString subdirPath; rv = subdir->GetPath(subdirPath); NS_ENSURE_SUCCESS(rv, rv); // Form a URL as required by the crawl scope manager nsString subdirURL(NS_LITERAL_STRING("file:///")); subdirURL.Append(subdirPath); subdirURL.Append(NS_LITERAL_STRING("\\")); BOOL included; if (FAILED(crawlScopeManager->IncludedInCrawlScope(subdirURL.get(), &included))) return NS_ERROR_FAILURE; // If even one of the folders isn't there, we return false if (!included) return NS_OK; } *aResult = true; return NS_OK; }
HXBOOL CHXDirectory::DeleteFile(const char* szRelPath) { CHXString relativeStr(szRelPath); CHXString fullFileStr; OSErr err; // make a full pathname to the file if we don't have a // directory set (since some callers use a null dir // just to delete files) if (IsPartialMacPath(relativeStr) && (m_strPath.GetLength() > 0)) { // we're deleting for a partial path from the current obj directory fullFileStr = m_strPath; // add seperator if needed if ((fullFileStr.GetLength() > 0) && (fullFileStr.Right(1) != ':')) { fullFileStr += ':'; } fullFileStr += relativeStr; } else { HX_ASSERT(IsFullMacPath(relativeStr)); // object's dir not set, so this works only for full paths fullFileStr = relativeStr; } // delete the file err = CHXFileSpecUtils::RemoveFile(fullFileStr); // we really should return an error // this gets called frequently if the file doesn't exist - not an error // so return error only if file is busy return (err != fBsyErr); }