コード例 #1
0
ファイル: VFS.cpp プロジェクト: Rabarberpapa/rpcs3
vfsDevice* VFS::GetDeviceLocal(const wxString& local_path, wxString& path) const
{
	u32 max_eq;
	s32 max_i=-1;

	wxFileName file_path(local_path);
	file_path.Normalize();
	wxString mormalized_path = file_path.GetFullPath();

	for(u32 i=0; i<m_devices.GetCount(); ++i)
	{
		const u32 eq = m_devices[i].CmpLocalPath(mormalized_path);

		if(max_i < 0 || eq > max_eq)
		{
			max_eq = eq;
			max_i = i;
		}
	}

	if(max_i < 0) return nullptr;

	path = vfsDevice::GetPs3Path(m_devices[max_i].GetPs3Path(), local_path(max_eq, local_path.Len() - max_eq));
	return &m_devices[max_i];
}
コード例 #2
0
ファイル: rfs-pull-tree.cpp プロジェクト: newenclave/vtrc
 void pull_tree(vtrc::client::vtrc_client_sptr &client,
             const interfaces::remote_fs       &impl,
             const std::string                 &remote_path )
 {
     fs::path local_path( remote_path );
     pull_tree( client, impl, remote_path, local_path.leaf( ).string( ) );
 }
コード例 #3
0
ファイル: ControlSocket.cpp プロジェクト: bugiii/filezilla3ex
void CControlSocket::CreateLocalDir(const wxString &local_file)
{
	wxString file;
	CLocalPath local_path(local_file, &file);
	if (local_path.empty() || !local_path.HasParent())
		return;

	// Only go back as far as needed. On comparison, wxWidgets'
	// wxFileName::Mkdir always starts at the root.
	std::list<wxString> segments;
	while (!local_path.Exists() && local_path.HasParent())
	{
		wxString segment;
		local_path.MakeParent(&segment);
		segments.push_front(segment);
	}

	CLocalPath last_successful;
	for (std::list<wxString>::const_iterator iter = segments.begin(); iter != segments.end(); ++iter)
	{
		local_path.AddSegment(*iter);

#ifdef __WXMSW__
		BOOL res = CreateDirectory(local_path.GetPath(), 0);
		if (!res && GetLastError() != ERROR_ALREADY_EXISTS)
			break;
#else
		const wxCharBuffer s = local_path.GetPath().fn_str();

		int res = mkdir(s, 0777);
		if (res && errno != EEXIST)
			break;
#endif
		last_successful = local_path;
	}

	if (last_successful.empty())
		return;

	// Send out notification
	CLocalDirCreatedNotification *n = new CLocalDirCreatedNotification;
	n->dir = last_successful;
	m_pEngine->AddNotification(n);
}
コード例 #4
0
ファイル: LocalTreeView.cpp プロジェクト: idgaf/FileZilla3
void CLocalTreeView::OnMenuDelete(wxCommandEvent& event)
{
	if (!m_contextMenuItem.IsOk())
		return;

	wxString path = GetDirFromItem(m_contextMenuItem);

	CLocalPath local_path(path);
	if (!local_path.HasParent() || !local_path.IsWriteable())
		return;

	if (!CLocalFileSystem::RecursiveDelete(path, this))
		wxGetApp().DisplayEncodingWarning();

	wxTreeItemId item = GetSelection();
	while (item && item != m_contextMenuItem)
		item = GetItemParent(item);

	if (!item)
	{
		if (GetItemParent(m_contextMenuItem) == GetSelection())
			m_pState->RefreshLocal();
		else
			Refresh();
		return;
	}

	if (path.Last() == wxFileName::GetPathSeparator())
		path.RemoveLast();
	int pos = path.Find(wxFileName::GetPathSeparator(), true);
	if (pos < 1)
		path = _T("/");
	else
		path = path.Left(pos);

	m_pState->SetLocalDir(path);
	Refresh();
}
コード例 #5
0
ファイル: LocalTreeView.cpp プロジェクト: idgaf/FileZilla3
void CLocalTreeView::OnEndLabelEdit(wxTreeEvent& event)
{
	if (event.IsEditCancelled())
	{
		event.Veto();
		return;
	}

	wxTreeItemId item = event.GetItem();

#ifdef __WXMSW__
	if (item == m_desktop || item == m_documents)
	{
		wxBell();
		event.Veto();
		return;
	}
#endif

	wxString path = GetDirFromItem(item);

	CLocalPath local_path(path);
	if (!local_path.HasParent() || !local_path.IsWriteable())
	{
		wxBell();
		event.Veto();
		return;
	}

	if (path.Last() == wxFileName::GetPathSeparator())
		path.RemoveLast();

	int pos = path.Find(wxFileName::GetPathSeparator(), true);
	wxASSERT(pos != -1);

	wxString parent = path.Left(pos + 1);

	const wxString& oldName = GetItemText(item);
	const wxString& newName = event.GetLabel();
	if (newName == _T(""))
	{
		wxBell();
		event.Veto();
		return;
	}

	wxASSERT(parent + oldName == path);

	if (oldName == newName)
		return;

	if (!Rename(this, parent, oldName, newName))
	{
		event.Veto();
		return;
	}

	// We may call SetLocalDir, item might be deleted by it, so
	// if we don't rename item now and veto the event, wxWidgets
	// might access deleted item.
	event.Veto();
	SetItemText(item, newName);

	wxTreeItemId currentSel = GetSelection();
	if (currentSel == wxTreeItemId())
	{
		Refresh();
		return;
	}

	if (item == currentSel)
	{
		m_pState->SetLocalDir(parent + newName);
		return;
	}

	wxString sub;

	wxTreeItemId tmp = currentSel;
	while (tmp != GetRootItem() && tmp != item)
	{
		sub = wxFileName::GetPathSeparator() + GetItemText(tmp) + sub;
		tmp = GetItemParent(tmp);
	}

	if (tmp == GetRootItem())
	{
		// Rename unrelated to current selection
		return;
	}

	// Current selection below renamed item
	m_pState->SetLocalDir(parent + newName + sub);
}