STDMETHODIMP GuestSessionWrap::COMGETTER(Directories)(ComSafeArrayOut(IGuestDirectory *, aDirectories)) { LogRelFlow(("{%p} %s: enter aDirectories=%p\n", this, "GuestSession::getDirectories", aDirectories)); VirtualBoxBase::clearError(); HRESULT hrc; try { CheckComArgOutPointerValidThrow(aDirectories); AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) throw autoCaller.rc(); hrc = getDirectories(ArrayComTypeOutConverter<IGuestDirectory>(ComSafeArrayOutArg(aDirectories)).array()); } catch (HRESULT hrc2) { hrc = hrc2; } catch (...) { hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS); } LogRelFlow(("{%p} %s: leave *aDirectories=%zu hrc=%Rhrc\n", this, "GuestSession::getDirectories", ComSafeArraySize(*aDirectories), hrc)); return hrc; }
bool Directory::delete_() throw() { ArrayList<File> files = getFiles(); ArrayList<Directory> directories = getDirectories(); for(File& i : files) if(! i.delete_()) return false; for(Directory& i : directories) if(! i.delete_()) return false; return FileImplementation::deleteDirectory(mPath); }
void ShareManager::runRefresh(function<void (float)> progressF) { auto dirs = getDirectories(); // Don't need to refresh if no directories are shared if(dirs.empty()) refreshDirs = false; if(refreshDirs) { HashManager::HashPauser pauser; string shareName = id.empty() ? string() : " for " + id; LogManager::getInstance()->message(_("File list refresh initiated ") + shareName ); lastFullUpdate = GET_TICK(); vector<pair<Directory::Ptr, string>> newDirs; float progressCounter = 0, dirCount = dirs.size(); // Make sure that the cache is updated. updateFilterCache(); for(auto& i: dirs) { if(checkHidden(i.second)) { auto dp = buildTree(i.second); dp->setName(i.first); newDirs.emplace_back(dp, i.second); } if(progressF) { progressF(++progressCounter / dirCount); } } { Lock l(cs); directories.clear(); for(auto& i: newDirs) { merge(i.first, i.second); } rebuildIndices(); } refreshDirs = false; LogManager::getInstance()->message(_("File list refresh finished ") + shareName ); } if(update) { ClientManager::getInstance()->infoUpdated(); } refreshing.clear(); }
NS_IMETHODIMP nsAbBSDirectory::DeleteDirectory(nsIAbDirectory *directory) { NS_ENSURE_ARG_POINTER(directory); nsresult rv = EnsureInitialized(); NS_ENSURE_SUCCESS(rv, rv); DIR_Server *server = nsnull; mServers.Get(directory, &server); if (!server) return NS_ERROR_FAILURE; GetDirectories getDirectories(server); mServers.EnumerateRead(GetDirectories_getDirectory, (void*)&getDirectories); DIR_DeleteServerFromList(server); nsCOMPtr<nsIAbDirFactoryService> dirFactoryService = do_GetService(NS_ABDIRFACTORYSERVICE_CONTRACTID,&rv); NS_ENSURE_SUCCESS (rv, rv); PRUint32 count = getDirectories.directories.Count(); nsCOMPtr<nsIAbManager> abManager = do_GetService(NS_ABMANAGER_CONTRACTID); for (PRUint32 i = 0; i < count; i++) { nsCOMPtr<nsIAbDirectory> d = getDirectories.directories[i]; mServers.Remove(d); rv = mSubDirectories.RemoveObject(d); if (abManager) abManager->NotifyDirectoryDeleted(this, d); nsCOMPtr<nsIRDFResource> resource(do_QueryInterface (d, &rv)); nsCString uri; resource->GetValueUTF8(uri); nsCOMPtr<nsIAbDirFactory> dirFactory; rv = dirFactoryService->GetDirFactory(uri, getter_AddRefs(dirFactory)); if (NS_FAILED(rv)) continue; rv = dirFactory->DeleteDirectory(d); } return rv; }
NS_IMETHODIMP nsAbBSDirectory::DeleteDirectory(nsIAbDirectory *directory) { NS_ENSURE_ARG_POINTER(directory); nsresult rv = EnsureInitialized(); NS_ENSURE_SUCCESS(rv, rv); DIR_Server *server = nullptr; mServers.Get(directory, &server); if (!server) return NS_ERROR_FAILURE; struct GetDirectories { GetDirectories(DIR_Server* aServer) : mServer(aServer) { } nsCOMArray<nsIAbDirectory> directories; DIR_Server* mServer; }; GetDirectories getDirectories(server); for (auto iter = mServers.Iter(); !iter.Done(); iter.Next()) { if (iter.UserData() == getDirectories.mServer) { nsCOMPtr<nsIAbDirectory> abDir = do_QueryInterface(iter.Key()); getDirectories.directories.AppendObject(abDir); } } DIR_DeleteServerFromList(server); nsCOMPtr<nsIAbDirFactoryService> dirFactoryService = do_GetService(NS_ABDIRFACTORYSERVICE_CONTRACTID,&rv); NS_ENSURE_SUCCESS (rv, rv); uint32_t count = getDirectories.directories.Count(); nsCOMPtr<nsIAbManager> abManager = do_GetService(NS_ABMANAGER_CONTRACTID); for (uint32_t i = 0; i < count; i++) { nsCOMPtr<nsIAbDirectory> d = getDirectories.directories[i]; mServers.Remove(d); mSubDirectories.RemoveObject(d); if (abManager) abManager->NotifyDirectoryDeleted(this, d); nsCString uri; rv = d->GetURI(uri); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsIAbDirFactory> dirFactory; rv = dirFactoryService->GetDirFactory(uri, getter_AddRefs(dirFactory)); if (NS_FAILED(rv)) continue; rv = dirFactory->DeleteDirectory(d); } return rv; }