コード例 #1
0
ファイル: FTPSession.cpp プロジェクト: Praymundo/NppFTP
FileObject* FTPSession::FindPathObject(const char * filepath) {
	if (!filepath)
		return NULL;

	char tempstr[MAX_PATH];
	strcpy(tempstr, filepath);

	FileObject * current = m_rootObject;

	char * curname = strtok (tempstr, "/");

	while(curname) {
		if (current->GetChildCount() == 0)	//search did not finish, but cannot find child
			return NULL;

		int i = 0;
		int count = current->GetChildCount();
		for(i = 0; i < count; i++) {
			if ( !strcmp( current->GetChild(i)->GetName(), curname ) ) {
				current = current->GetChild(i);
				curname = strtok (NULL, "/");
				break;
			}
		}

		if (i == count)	//none of the children match
			return NULL;
	}

	return current;
}
コード例 #2
0
ファイル: FTPWindow.cpp プロジェクト: Praymundo/NppFTP
int FTPWindow::OnConnect(int code) {
	if (code != 0)	//automated connect
		return 0;



	FileObject * root = m_ftpSession->GetRootObject();
	m_treeview.AddRoot(root);

	FileObject * last = root;
	while(last->GetChildCount() > 0) {
		last = last->GetChild(0);
	}

	m_treeview.EnsureObjectVisible(last);
	TreeView_Select(m_treeview.GetHWND(), last->GetData(), TVGN_CARET);
	m_ftpSession->GetDirectory(last->GetPath());

	TCHAR * info = SU::TSprintfNB(TEXT("Connected to %T"), m_ftpSession->GetCurrentProfile()->GetName());
	SetInfo(info);
	delete [] info;

	SetToolbarState();

	return 0;
}