本文整理汇总了C++中CServerPath::IsEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ CServerPath::IsEmpty方法的具体用法?C++ CServerPath::IsEmpty怎么用?C++ CServerPath::IsEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CServerPath
的用法示例。
在下文中一共展示了CServerPath::IsEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetSyncBrowse
bool CState::SetSyncBrowse(bool enable, const CServerPath& assumed_remote_root /*=CServerPath()*/)
{
if (enable != m_sync_browse.local_root.empty())
return enable;
if (!enable)
{
wxASSERT(assumed_remote_root.IsEmpty());
m_sync_browse.local_root.clear();
m_sync_browse.remote_root.Clear();
m_sync_browse.is_changing = false;
NotifyHandlers(STATECHANGE_SYNC_BROWSE);
return false;
}
if (!m_pDirectoryListing && assumed_remote_root.IsEmpty())
{
NotifyHandlers(STATECHANGE_SYNC_BROWSE);
return false;
}
m_sync_browse.is_changing = false;
m_sync_browse.local_root = m_localDir;
if (assumed_remote_root.IsEmpty())
m_sync_browse.remote_root = m_pDirectoryListing->path;
else
{
m_sync_browse.remote_root = assumed_remote_root;
m_sync_browse.is_changing = true;
m_sync_browse.compare = false;
}
while (m_sync_browse.local_root.HasParent() && m_sync_browse.remote_root.HasParent() &&
m_sync_browse.local_root.GetLastSegment() == m_sync_browse.remote_root.GetLastSegment())
{
m_sync_browse.local_root.MakeParent();
m_sync_browse.remote_root = m_sync_browse.remote_root.GetParent();
}
NotifyHandlers(STATECHANGE_SYNC_BROWSE);
return true;
}
示例2: OnSearch
void CSearchDialog::OnSearch(wxCommandEvent& event)
{
if (!m_pState->IsRemoteIdle())
{
wxBell();
return;
}
CServerPath path;
const CServer* pServer = m_pState->GetServer();
if (!pServer)
{
wxMessageBox(_("Connection to server lost."), _("Remote file search"), wxICON_EXCLAMATION);
return;
}
path.SetType(pServer->GetType());
if (!path.SetPath(XRCCTRL(*this, "ID_PATH", wxTextCtrl)->GetValue()) || path.IsEmpty())
{
wxMessageBox(_("Need to enter valid remote path"), _("Remote file search"), wxICON_EXCLAMATION);
return;
}
m_search_root = path;
// Prepare filter
wxString error;
if (!ValidateFilter(error, true))
{
wxMessageBox(wxString::Format(_("Invalid search conditions: %s"), error.c_str()), _("Remote file search"), wxICON_EXCLAMATION);
return;
}
m_search_filter = GetFilter();
if (!CFilterManager::CompileRegexes(m_search_filter))
{
wxMessageBox(_("Invalid regular expression in search conditions."), _("Remote file search"), wxICON_EXCLAMATION);
return;
}
m_search_filter.matchCase = XRCCTRL(*this, "ID_CASE", wxCheckBox)->GetValue();
// Delete old results
m_results->ClearSelection();
m_results->m_indexMapping.clear();
m_results->m_fileData.clear();
m_results->SetItemCount(0);
m_visited.clear();
m_results->RefreshListOnly(true);
m_results->GetFilelistStatusBar()->Clear();
// Start
m_searching = true;
m_pState->GetRecursiveOperationHandler()->AddDirectoryToVisitRestricted(path, _T(""), true);
std::list<CFilter> filters; // Empty, recurse into everything
m_pState->GetRecursiveOperationHandler()->StartRecursiveOperation(CRecursiveOperation::recursive_list, path, filters, true);
}
示例3: ParsePwdReply
bool CControlSocket::ParsePwdReply(wxString reply, bool unquoted /*=false*/, const CServerPath& defaultPath /*=CServerPath()*/)
{
if (!unquoted)
{
int pos1 = reply.Find('"');
int pos2 = reply.Find('"', true);
if (pos1 == -1 || pos1 >= pos2)
{
pos1 = reply.Find('\'');
pos2 = reply.Find('\'', true);
if (pos1 != -1 && pos1 < pos2)
LogMessage(__TFILE__, __LINE__, this, Debug_Info, _T("Broken server sending single-quoted path instead of double-quoted path."));
}
if (pos1 == -1 || pos1 >= pos2)
{
LogMessage(__TFILE__, __LINE__, this, Debug_Info, _T("Broken server, no quoted path found in pwd reply, trying first token as path"));
pos1 = reply.Find(' ');
if (pos1 != -1)
{
reply = reply.Mid(pos1 + 1);
pos2 = reply.Find(' ');
if (pos2 != -1)
reply = reply.Left(pos2);
}
else
reply = _T("");
}
else
{
reply = reply.Mid(pos1 + 1, pos2 - pos1 - 1);
reply.Replace(_T("\"\""), _T("\""));
}
}
m_CurrentPath.SetType(m_pCurrentServer->GetType());
if (reply == _T("") || !m_CurrentPath.SetPath(reply))
{
if (reply != _T(""))
LogMessage(::Error, _("Failed to parse returned path."));
else
LogMessage(::Error, _("Server returned empty path."));
if (!defaultPath.IsEmpty())
{
LogMessage(Debug_Warning, _T("Assuming path is '%s'."), defaultPath.GetPath().c_str());
m_CurrentPath = defaultPath;
return true;
}
return false;
}
return true;
}
示例4: OnMenuUpload
void CLocalListView::OnMenuUpload(wxCommandEvent& event)
{
const CServer* pServer = m_pState->GetServer();
if (!pServer)
{
wxBell();
return;
}
bool added = false;
bool queue_only = event.GetId() == XRCID("ID_ADDTOQUEUE");
long item = -1;
for (;;)
{
item = GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
if (!item && m_hasParent)
continue;
if (item == -1)
break;
const CLocalFileData *data = GetData(item);
if (!data)
break;
if (data->flags == fill)
continue;
CServerPath path = m_pState->GetRemotePath();
if (path.IsEmpty())
{
wxBell();
break;
}
if (data->dir)
{
path.ChangePath(data->name);
CLocalPath localPath(m_dir);
localPath.AddSegment(data->name);
m_pQueue->QueueFolder(event.GetId() == XRCID("ID_ADDTOQUEUE"), false, localPath, path, *pServer);
}
else
{
m_pQueue->QueueFile(queue_only, false, data->name, wxEmptyString, CLocalPath(m_dir), path, *pServer, data->size);
added = true;
}
}
if (added)
m_pQueue->QueueFile_Finish(!queue_only);
}
示例5: ListExpand
bool CRemoteTreeView::ListExpand(wxTreeItemId item)
{
const CServerPath path = GetPathFromItem(item);
wxASSERT(!path.IsEmpty());
if (path.IsEmpty())
return false;
CDirectoryListing listing;
if (m_pState->m_pEngine->CacheLookup(path, listing) == FZ_REPLY_OK)
RefreshItem(item, listing, false);
else
{
SetItemImages(item, true);
wxTreeItemId child = GetLastChild(item);
if (!child || GetItemText(child) == _T(""))
return false;
}
return true;
}
示例6: InvalidatePath
void CPathCache::InvalidatePath(const CServer& server, const CServerPath& path, const wxString& subdir /*=_T("")*/)
{
tCacheIterator iter = m_cache.find(server);
if (iter == m_cache.end())
return;
CSourcePath sourcePath;
sourcePath.source = path;
sourcePath.subdir = subdir;
CServerPath target;
tServerCacheIterator serverIter = iter->second->find(sourcePath);
if (serverIter != iter->second->end())
{
target = serverIter->second;
iter->second->erase(serverIter);
}
if (target.IsEmpty() && subdir != _T(""))
{
target = path;
if (!target.AddSegment(subdir))
return;
}
if (!target.IsEmpty())
{
// Unfortunately O(n), don't know of a faster way.
for (std::map<CSourcePath, CServerPath>::iterator serverIter = iter->second->begin(); serverIter != iter->second->end();)
{
if (serverIter->second == target || target.IsParentOf(serverIter->second, false))
iter->second->erase(serverIter++);
else if (serverIter->first.source == target || target.IsParentOf(serverIter->first.source, false))
iter->second->erase(serverIter++);
else
++serverIter;
}
}
}
示例7: Store
void CPathCache::Store(const CServer& server, const CServerPath& target, const CServerPath& source, const wxString subdir/*=_T("")*/)
{
wxASSERT(!target.IsEmpty() && !source.IsEmpty());
tServerCache *pServerCache;
tCacheIterator iter = m_cache.find(server);
if (iter != m_cache.end())
pServerCache = iter->second;
else
{
pServerCache = new tServerCache;
m_cache[server] = pServerCache;
}
tServerCache &serverCache = *pServerCache;
CSourcePath sourcePath;
sourcePath.source = source;
sourcePath.subdir = subdir;
serverCache[sourcePath] = target;
}
示例8: InvalidateCurrentWorkingDir
void CControlSocket::InvalidateCurrentWorkingDir(const CServerPath& path)
{
wxASSERT(!path.IsEmpty());
if (m_CurrentPath.IsEmpty())
return;
if (m_CurrentPath == path || path.IsParentOf(m_CurrentPath, false))
{
if (m_pCurOpData)
m_invalidateCurrentPath = true;
else
m_CurrentPath.Clear();
}
}
示例9: OnSelectionChanged
void CRemoteTreeView::OnSelectionChanged(wxTreeEvent& event)
{
if (event.GetItem() != m_ExpandAfterList)
m_ExpandAfterList = wxTreeItemId();
if (m_busy)
return;
if (!m_pState->IsRemoteIdle())
{
wxBell();
return;
}
wxTreeItemId item = event.GetItem();
if (!item)
return;
const CServerPath path = GetPathFromItem(item);
wxASSERT(!path.IsEmpty());
if (path.IsEmpty())
return;
m_pState->ChangeRemoteDir(path);
}
示例10: Lookup
CServerPath CPathCache::Lookup(const CServer& server, const CServerPath& source, const wxString subdir /*=_T("")*/)
{
const tCacheConstIterator iter = m_cache.find(server);
if (iter == m_cache.end())
return CServerPath();
CServerPath result = Lookup(*iter->second, source, subdir);
if (result.IsEmpty())
m_misses++;
else
m_hits++;
return result;
}
示例11: OnMenuDelete
void CRemoteTreeView::OnMenuDelete(wxCommandEvent& event)
{
if (!m_pState->IsRemoteIdle())
return;
if (!m_contextMenuItem)
return;
const CServerPath& path = GetPathFromItem(m_contextMenuItem);
if (path.IsEmpty())
return;
if (wxMessageBox(_("Really delete all selected files and/or directories?"), _("Confirmation needed"), wxICON_QUESTION | wxYES_NO, this) != wxYES)
return;
const bool hasParent = path.HasParent();
CRecursiveOperation* pRecursiveOperation = m_pState->GetRecursiveOperationHandler();
CServerPath startDir;
if (hasParent)
{
const wxString& name = GetItemText(m_contextMenuItem);
startDir = path.GetParent();
pRecursiveOperation->AddDirectoryToVisit(startDir, name);
}
else
{
startDir = path;
pRecursiveOperation->AddDirectoryToVisit(startDir, _T(""));
}
CServerPath currentPath;
const wxTreeItemId selected = GetSelection();
if (selected)
currentPath = GetPathFromItem(selected);
if (!currentPath.IsEmpty() && (path == currentPath || path.IsParentOf(currentPath, false)))
currentPath = startDir;
CFilterManager filter;
pRecursiveOperation->StartRecursiveOperation(CRecursiveOperation::recursive_delete, startDir, filter.GetActiveFilters(false), !hasParent, currentPath);
}
示例12: MakeDir
int CFileZillaApi::MakeDir(const CServerPath &path)
{
//Check if call allowed
if (!m_bInitialized)
return FZ_REPLY_NOTINITIALIZED;
if (IsConnected()==FZ_REPLY_NOTCONNECTED)
return FZ_REPLY_NOTCONNECTED;
if (IsBusy()==FZ_REPLY_BUSY)
return FZ_REPLY_BUSY;
if (path.IsEmpty() || !path.HasParent())
return FZ_REPLY_INVALIDPARAM;
t_command command;
command.id=FZ_COMMAND_MAKEDIR;
command.path=path;
m_pMainThread->Command(command);
if (m_hOwnerWnd)
return FZ_REPLY_WOULDBLOCK;
else
return m_pMainThread->LastOperationSuccessful()?FZ_REPLY_OK:FZ_REPLY_ERROR;
return FZ_REPLY_ERROR;
}
示例13: Load
bool CSearchDialog::Load()
{
if (!wxDialogEx::Load(m_parent, _T("ID_SEARCH")))
return false;
/* XRCed complains if adding a status bar to a dialog, so do it here instead */
CFilelistStatusBar* pStatusBar = new CFilelistStatusBar(this);
pStatusBar->SetEmptyString(_("No search results"));
GetSizer()->Add(pStatusBar, 0, wxGROW);
if (!CreateListControl(filter_name | filter_size | filter_path | filter_date))
return false;
m_results = new CSearchDialogFileList(this, m_pState, 0);
ReplaceControl(XRCCTRL(*this, "ID_RESULTS", wxWindow), m_results);
m_results->SetFilelistStatusBar(pStatusBar);
const CServerPath path = m_pState->GetRemotePath();
if (!path.IsEmpty())
XRCCTRL(*this, "ID_PATH", wxTextCtrl)->ChangeValue(path.GetPath());
SetCtrlState();
m_pWindowStateManager = new CWindowStateManager(this);
m_pWindowStateManager->Restore(OPTION_SEARCH_SIZE, wxSize(750, 500));
Layout();
LoadConditions();
EditFilter(m_search_filter);
XRCCTRL(*this, "ID_CASE", wxCheckBox)->SetValue(m_search_filter.matchCase);
return true;
}
示例14: AddBookmark
bool CSiteManager::AddBookmark(wxString sitePath, const wxString& name, const wxString &local_dir, const CServerPath &remote_dir, bool sync)
{
if (local_dir.empty() && remote_dir.IsEmpty())
return false;
if (sitePath[0] != '0')
return false;
sitePath = sitePath.Mid(1);
// We have to synchronize access to sitemanager.xml so that multiple processed don't write
// to the same file or one is reading while the other one writes.
CInterProcessMutex mutex(MUTEX_SITEMANAGER);
CXmlFile file;
TiXmlElement* pDocument = file.Load(_T("sitemanager"));
if (!pDocument)
{
wxString msg = file.GetError() + _T("\n") + _("The bookmark could not be added.");
wxMessageBox(msg, _("Error loading xml file"), wxICON_ERROR);
return false;
}
TiXmlElement* pElement = pDocument->FirstChildElement("Servers");
if (!pElement)
return false;
std::list<wxString> segments;
if (!UnescapeSitePath(sitePath, segments))
{
wxMessageBox(_("Site path is malformed."), _("Invalid site path"));
return 0;
}
TiXmlElement* pChild = GetElementByPath(pElement, segments);
if (!pChild || strcmp(pChild->Value(), "Server"))
{
wxMessageBox(_("Site does not exist."), _("Invalid site path"));
return 0;
}
// Bookmarks
TiXmlElement *pInsertBefore = 0;
TiXmlElement* pBookmark;
for (pBookmark = pChild->FirstChildElement("Bookmark"); pBookmark; pBookmark = pBookmark->NextSiblingElement("Bookmark"))
{
TiXmlHandle handle(pBookmark);
wxString old_name = GetTextElement_Trimmed(pBookmark, "Name");
if (old_name.empty())
continue;
if (name == old_name)
{
wxMessageBox(_("Name of bookmark already exists."), _("New bookmark"), wxICON_EXCLAMATION);
return false;
}
if (name < old_name && !pInsertBefore)
pInsertBefore = pBookmark;
}
if (pInsertBefore)
pBookmark = pChild->InsertBeforeChild(pInsertBefore, TiXmlElement("Bookmark"))->ToElement();
else
pBookmark = pChild->LinkEndChild(new TiXmlElement("Bookmark"))->ToElement();
AddTextElement(pBookmark, "Name", name);
if (!local_dir.empty())
AddTextElement(pBookmark, "LocalDir", local_dir);
if (!remote_dir.IsEmpty())
AddTextElement(pBookmark, "RemoteDir", remote_dir.GetSafePath());
if (sync)
AddTextElementRaw(pBookmark, "SyncBrowsing", "1");
wxString error;
if (!file.Save(&error))
{
if (COptions::Get()->GetOptionVal(OPTION_DEFAULT_KIOSKMODE) == 2)
return true;
wxString msg = wxString::Format(_("Could not write \"%s\", the selected sites could not be exported: %s"), file.GetFileName().GetFullPath().c_str(), error.c_str());
wxMessageBox(msg, _("Error writing xml file"), wxICON_ERROR);
}
return true;
}
示例15: GetBookmarks
bool CSiteManager::GetBookmarks(wxString sitePath, std::list<wxString> &bookmarks)
{
wxChar c = sitePath[0];
if (c != '0' && c != '1')
return false;
sitePath = sitePath.Mid(1);
// We have to synchronize access to sitemanager.xml so that multiple processed don't write
// to the same file or one is reading while the other one writes.
CInterProcessMutex mutex(MUTEX_SITEMANAGER);
CXmlFile file;
TiXmlElement* pDocument = 0;
if (c == '0')
pDocument = file.Load(_T("sitemanager"));
else
{
const wxString& defaultsDir = wxGetApp().GetDefaultsDir();
if (defaultsDir == _T(""))
return false;
pDocument = file.Load(wxFileName(defaultsDir, _T("fzdefaults.xml")));
}
if (!pDocument)
{
wxMessageBox(file.GetError(), _("Error loading xml file"), wxICON_ERROR);
return false;
}
TiXmlElement* pElement = pDocument->FirstChildElement("Servers");
if (!pElement)
return false;
std::list<wxString> segments;
if (!UnescapeSitePath(sitePath, segments))
{
wxMessageBox(_("Site path is malformed."), _("Invalid site path"));
return 0;
}
TiXmlElement* pChild = GetElementByPath(pElement, segments);
if (pChild && !strcmp(pChild->Value(), "Bookmark"))
pChild = pChild->Parent()->ToElement();
if (!pChild || strcmp(pChild->Value(), "Server"))
return 0;
// Bookmarks
for (TiXmlElement* pBookmark = pChild->FirstChildElement("Bookmark"); pBookmark; pBookmark = pBookmark->NextSiblingElement("Bookmark"))
{
TiXmlHandle handle(pBookmark);
wxString name = GetTextElement_Trimmed(pBookmark, "Name");
if (name.empty())
continue;
wxString localPath;
CServerPath remotePath;
TiXmlText* localDir = handle.FirstChildElement("LocalDir").FirstChild().Text();
if (localDir)
localPath = ConvLocal(localDir->Value());
TiXmlText* remoteDir = handle.FirstChildElement("RemoteDir").FirstChild().Text();
if (remoteDir)
remotePath.SetSafePath(ConvLocal(remoteDir->Value()));
if (localPath.empty() && remotePath.IsEmpty())
continue;
bookmarks.push_back(name);
}
return true;
}