Example #1
0
void CDlgFiles::OnDblclkLocalList( NMHDR* pNMHDR, LRESULT* pResult )
	{
	*pResult = 0;

	if ( 1 != m_LocalList.GetSelectedCount( ) )
		return;

	int iSelected = m_LocalList.GetNextItem( -1, LVIS_SELECTED );
	if ( -1 == iSelected )
		return;

	CLocalFileBase* pFile = ( CLocalFileBase* )m_LocalList.GetItemData( iSelected );
	if ( pFile->IsFolder( ) )
		{
		if ( !pFile->IsExpanded( ) )
			pFile->GetFileList( );

		m_Position[ m_pCurrentLocal ] = ( void* )iSelected;

		m_pCurrentLocal = ( CLocalFolder* )pFile;
		RefreshLocal( );
		}
	else
		{
		if ( !GetPrivileges( )->m_bUploadFiles )
			return;

		CString sPath;
		CLocalFileBase::CreatePath( m_pCurrentLocal, sPath );
		sPath = sPath + pFile->GetItemName( );
		m_pServerDialog->UploadFile( sPath, m_pCurrentRemote );
		}
	}
Example #2
0
void CDlgFiles::OnLocalUp( )
	{
	if ( m_pCurrentLocal->GetParent( ) )
		{
		m_pCurrentLocal = m_pCurrentLocal->GetParent( );
		RefreshLocal( );
		}
	}
Example #3
0
void CDlgFiles::OnLocalRefresh( )
	{
	if ( m_pCurrentLocal )
		{
		m_pCurrentLocal->GetFileList( );
		RefreshLocal( );
		}
	}
Example #4
0
void CDlgFiles::HandleDefaultDirectory( )
	{
	CString sDefault ( m_pServerDialog->m_pServerData->GetServerOptions( )->m_sDefaultDirectory );

	if ( sDefault.IsEmpty( ) )
		return;

	CLocalFolder* pCurrent = &m_Root;
	CLocalFileBase* pChild;

	int iPos;
	CString sBase;

	while ( !sDefault.IsEmpty( ) )
		{
		iPos = sDefault.Find( '\\' );
		if ( -1 == iPos )
			{
			sBase = sDefault;
			sDefault.Empty( );
			}
		else
			{
			sBase = sDefault.Left( iPos );
			sDefault = sDefault.Mid( iPos + 1 );
			}
		if ( ( 2 == sBase.GetLength( ) ) && ( sBase[ 1 ] == ':' ) )
			// Cas particulier de la racine, qui comporte un anti-slash à la fin
			sBase += '\\';

		bool bFound = false;
		for ( int iDir = 0; iDir < pCurrent->GetChildCount( ); iDir++ )
			{
			pChild = pCurrent->GetChild( iDir );
			if ( !pChild->IsFolder( ) )
				continue;

			if ( 0 == sBase.CompareNoCase( pChild->GetItemName( ) ) )
				{
				pCurrent = ( CLocalFolder* )pChild;
				bFound = true;
				break;
				}
			}
		if ( !bFound )
			return;

		m_pCurrentLocal = pCurrent;
		pCurrent->GetFileList( );
		RefreshLocal( );
		}

	OnRemoteExpand( );
	}
Example #5
0
void CDlgFiles::OnLocalName( )
	{
	if ( !m_pCurrentLocal->GetParent( ) )
		return;

	CLocalFolder* pFolder = m_pCurrentLocal;

	CMenu menu;
	menu.CreatePopupMenu( );

	int iLevel = 0;
	CString sTemp;
	while ( pFolder )
		{
		CLocalFileBase::CreatePath( pFolder, sTemp );
		if ( sTemp.IsEmpty( ) )
			sTemp = LOCAL_ROOT;
		FixNameForDisplay( sTemp );
		menu.AppendMenu( MF_STRING, FIRST_ITEM + iLevel++, sTemp );
		pFolder = pFolder->GetParent( );
		}

	POINT pp;
	GetCursorPos( &pp );
	UINT uiCommand = menu.TrackPopupMenu( TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_NONOTIFY | TPM_RETURNCMD, pp.x, pp.y, this );
	menu.DestroyMenu( );
	if ( !uiCommand )
		return;

	uiCommand = uiCommand - FIRST_ITEM;
	while ( uiCommand )
		{
		m_pCurrentLocal = m_pCurrentLocal->GetParent( );
		ASSERT( m_pCurrentRemote );
		uiCommand--;
		}
	RefreshLocal( );
	}
void CState::HandleDroppedFiles(const wxFileDataObject* pFileDataObject, const CLocalPath& path, bool copy)
{
	const wxArrayString &files = pFileDataObject->GetFilenames();
	if (!files.Count())
		return;

#ifdef __WXMSW__
	int len = 1;

	for (unsigned int i = 0; i < files.Count(); i++)
		len += files[i].Len() + 1;

	// SHFILEOPSTRUCT's pTo and pFrom accept null-terminated lists
	// of null-terminated filenames.
	wxChar* from = new wxChar[len];
	wxChar* p = from;
	for (unsigned int i = 0; i < files.Count(); i++)
	{
		wxStrcpy(p, files[i]);
		p += files[i].Len() + 1;
	}
	*p = 0; // End of list

	wxChar* to = new wxChar[path.GetPath().Len() + 2];
	wxStrcpy(to, path.GetPath());
	to[path.GetPath().Len() + 1] = 0; // End of list

	SHFILEOPSTRUCT op = {0};
	op.pFrom = from;
	op.pTo = to;
	op.wFunc = copy ? FO_COPY : FO_MOVE;
	op.hwnd = (HWND)m_pMainFrame->GetHandle();
	SHFileOperation(&op);

	delete [] to;
	delete [] from;
#else
	wxString error;
	for (unsigned int i = 0; i < files.Count(); i++)
	{
		const wxString& file(files[i]);

		int64_t size;
		bool is_link;
		CLocalFileSystem::local_fileType type = CLocalFileSystem::GetFileInfo(file, is_link, &size, 0, 0);
		if (type == CLocalFileSystem::file)
		{
			wxString name;
			CLocalPath sourcePath(file, &name);
			if (name.empty())
				continue;
			wxString target = path.GetPath() + name;
			if (file == target)
				continue;

			if (copy)
				wxCopyFile(file, target);
			else
				wxRenameFile(file, target);
		}
		else if (type == CLocalFileSystem::dir)
		{
			CLocalPath sourcePath(file);
			if (sourcePath == path || sourcePath.GetParent() == path)
				continue;
			if (sourcePath.IsParentOf(path))
			{
				error = _("A directory cannot be dragged into one of its subdirectories.");
				continue;
			}

			if (copy)
				RecursiveCopy(sourcePath, path);
			else
			{
				if (!sourcePath.HasParent())
					continue;
				wxRenameFile(file, path.GetPath() + sourcePath.GetLastSegment());
			}
		}
	}
	if (!error.empty())
		wxMessageBoxEx(error, _("Could not complete operation"));
#endif

	RefreshLocal();
}
Example #7
0
void CState::HandleDroppedFiles(const wxFileDataObject* pFileDataObject, const CLocalPath& path, bool copy)
{
	const wxArrayString &files = pFileDataObject->GetFilenames();
	if (!files.Count())
		return;

#ifdef __WXMSW__
	int len = 1;

	for (unsigned int i = 0; i < files.Count(); i++)
		len += files[i].Len() + 1;

	// SHFILEOPSTRUCT's pTo and pFrom accept null-terminated lists
	// of null-terminated filenames.
	wxChar* from = new wxChar[len];
	wxChar* p = from;
	for (unsigned int i = 0; i < files.Count(); i++)
	{
		wxStrcpy(p, files[i]);
		p += files[i].Len() + 1;
	}
	*p = 0; // End of list

	wxChar* to = new wxChar[path.GetPath().Len() + 2];
	wxStrcpy(to, path.GetPath());
	to[path.GetPath().Len() + 1] = 0; // End of list

	SHFILEOPSTRUCT op = {0};
	op.pFrom = from;
	op.pTo = to;
	op.wFunc = copy ? FO_COPY : FO_MOVE;
	op.hwnd = (HWND)m_pMainFrame->GetHandle();
	SHFileOperation(&op);

	delete [] to;
	delete [] from;
#else
	for (unsigned int i = 0; i < files.Count(); i++)
	{
		const wxString& file(files[i]);

		wxLongLong size;
		bool is_link;
		CLocalFileSystem::local_fileType type = CLocalFileSystem::GetFileInfo(file, is_link, &size, 0, 0);
		if (type == CLocalFileSystem::file)
		{
			wxString name;
			CLocalPath sourcePath(file, &name);
			if (name.empty())
				continue;
			if (copy)
				wxCopyFile(file, path.GetPath() + name);
			else
				wxRenameFile(file, path.GetPath() + name);
		}
		else if (type == CLocalFileSystem::dir)
		{
			if (copy)
				RecursiveCopy(CLocalPath(file), path);
			else
			{
				CLocalPath sourcePath(file);
				if (!sourcePath.HasParent())
					continue;
				wxRenameFile(file, path.GetPath() + sourcePath.GetLastSegment());
			}
		}
	}
#endif

	RefreshLocal();
}
Example #8
0
void CState::HandleDroppedFiles(const wxFileDataObject* pFileDataObject, wxString path, bool copy)
{
	if (path.Last() != wxFileName::GetPathSeparator())
		path += wxFileName::GetPathSeparator();

	const wxArrayString &files = pFileDataObject->GetFilenames();
	if (!files.Count())
		return;

#ifdef __WXMSW__
	int len = 1;

	for (unsigned int i = 0; i < files.Count(); i++)
		len += files[i].Len() + 1;

	wxChar* from = new wxChar[len];
	wxChar* p = from;
	for (unsigned int i = 0; i < files.Count(); i++)
	{
		wxStrcpy(p, files[i]);
		p += files[i].Len() + 1;
	}
	*p = 0;

	wxChar* to = new wxChar[path.Len() + 2];
	wxStrcpy(to, path);
	to[path.Len() + 1] = 0;

	SHFILEOPSTRUCT op = {0};
	op.pFrom = from;
	op.pTo = to;
	op.wFunc = copy ? FO_COPY : FO_MOVE;
	op.hwnd = (HWND)m_pMainFrame->GetHandle();
	SHFileOperation(&op);

	delete [] to;
	delete [] from;
#else
	for (unsigned int i = 0; i < files.Count(); i++)
	{
		const wxString& file = files[i];
		if (wxFile::Exists(file))
		{
			int pos = file.Find(wxFileName::GetPathSeparator(), true);
			if (pos == -1 || pos == (int)file.Len() - 1)
				continue;
			const wxString& name = file.Mid(pos + 1);
			if (copy)
				wxCopyFile(file, path + name);
			else
				wxRenameFile(file, path + name);
		}
		else if (wxDir::Exists(file))
		{
			if (copy)
				RecursiveCopy(file, path);
			else
			{
				int pos = file.Find(wxFileName::GetPathSeparator(), true);
				if (pos == -1 || pos == (int)file.Len() - 1)
					continue;
				const wxString& name = file.Mid(pos + 1);
				wxRenameFile(file, path + name);
			}
		}
	}
#endif

	RefreshLocal();
}