int CFileZillaEnginePrivate::List(const CListCommand &command) { if (!IsConnected()) return FZ_REPLY_NOTCONNECTED; if (command.GetPath().IsEmpty() && command.GetSubDir() != _T("")) return FZ_REPLY_SYNTAXERROR; if (command.GetFlags() & LIST_FLAG_LINK && command.GetSubDir() == _T("")) return FZ_REPLY_SYNTAXERROR; bool refresh = (command.GetFlags() & LIST_FLAG_REFRESH) != 0; bool avoid = (command.GetFlags() & LIST_FLAG_AVOID) != 0; if (refresh && avoid) return FZ_REPLY_SYNTAXERROR; if (!refresh && !command.GetPath().IsEmpty()) { const CServer* pServer = m_pControlSocket->GetCurrentServer(); if (pServer) { CServerPath path(CPathCache::Lookup(*pServer, command.GetPath(), command.GetSubDir())); if (path.IsEmpty() && command.GetSubDir().IsEmpty()) path = command.GetPath(); if (!path.IsEmpty()) { CDirectoryListing *pListing = new CDirectoryListing; CDirectoryCache cache; bool is_outdated = false; bool found = cache.Lookup(*pListing, *pServer, path, true, is_outdated); if (found && !is_outdated) { if (pListing->m_hasUnsureEntries) refresh = true; else { if (!avoid) { m_lastListDir = pListing->path; m_lastListTime = wxDateTime::Now(); CDirectoryListingNotification *pNotification = new CDirectoryListingNotification(pListing->path); AddNotification(pNotification); } delete pListing; return FZ_REPLY_OK; } } if (is_outdated) refresh = true; delete pListing; } } } if (IsBusy()) return FZ_REPLY_BUSY; m_pCurrentCommand = command.Clone(); return m_pControlSocket->List(command.GetPath(), command.GetSubDir(), command.GetFlags()); }
int CFileZillaEngine::CacheLookup(const CServerPath& path, CDirectoryListing& listing) { if (!IsConnected()) return FZ_REPLY_ERROR; wxASSERT(m_pControlSocket->GetCurrentServer()); CDirectoryCache cache; bool is_outdated = false; if (!cache.Lookup(listing, *m_pControlSocket->GetCurrentServer(), path, true, is_outdated)) return FZ_REPLY_ERROR; return FZ_REPLY_OK; }
int CFileZillaApi::List(const CServerPath& parent, CString dirname, int nListMode /*=FZ_LIST_USECACHE*/) { //Check if call allowed if (!m_bInitialized) return FZ_REPLY_NOTINITIALIZED; if (IsConnected()==FZ_REPLY_NOTCONNECTED) return FZ_REPLY_NOTCONNECTED; #ifndef MPEXT_NO_CACHE if ( (nListMode&(FZ_LIST_FORCECACHE|FZ_LIST_REALCHANGE))==(FZ_LIST_FORCECACHE|FZ_LIST_REALCHANGE) ) return FZ_REPLY_INVALIDPARAM; if (nListMode&FZ_LIST_FORCECACHE) nListMode|=FZ_LIST_USECACHE; #endif if (dirname==_MPT("") || parent.IsEmpty()) return FZ_REPLY_INVALIDPARAM; #ifndef MPEXT_NO_CACHE //Check if current dir is cached if (nListMode&FZ_LIST_USECACHE && !(nListMode&FZ_LIST_REALCHANGE)) { t_server server; BOOL res=m_pMainThread->GetCurrentServer(server); if (res) { t_directory *directory=new t_directory; CDirectoryCache cache; res=cache.Lookup(parent,dirname,server,*directory); if (res) { BOOL bExact=TRUE; if (nListMode & FZ_LIST_EXACT) for (int i=0;i<directory->num;i++) if (directory->direntry[i].bUnsure || (directory->direntry[i].size==-1 && !directory->direntry[i].dir)) { bExact=FALSE; break; } if (bExact) { m_pMainThread->SetWorkingDir(directory); delete directory; return FZ_REPLY_OK; } } delete directory; } } #endif if (m_pMainThread->IsBusy()) return FZ_REPLY_BUSY; #ifndef MPEXT_NO_CACHE if (nListMode&FZ_LIST_FORCECACHE) return FZ_REPLY_ERROR; #endif t_command command; command.id=FZ_COMMAND_LIST; command.path=parent; command.param1=dirname; command.param4=nListMode; m_pMainThread->Command(command); if (m_hOwnerWnd) return FZ_REPLY_WOULDBLOCK; else return m_pMainThread->LastOperationSuccessful()?FZ_REPLY_OK:FZ_REPLY_ERROR; }