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; }
HRESULT FTPWindow::OnDragOver(DWORD /*grfKeyState*/, POINTL pt, LPDWORD pdwEffect) { FileObject * fo = m_treeview.GetItemByPoint(pt); if (fo && fo->isDir()) { *pdwEffect = DROPEFFECT_COPY; TreeView_Select(m_treeview.GetHWND(), fo->GetData(), TVGN_DROPHILITE); m_currentDropObject = fo; return S_OK; } else { TreeView_Select(m_treeview.GetHWND(), NULL, TVGN_DROPHILITE); m_currentDropObject = NULL; } return S_OK; }
int FTPSession::GetDirectoryHierarchy(const char * inputDir) { if (!m_running) return -1; char *pathEntry; char* dir = SU::strdup(inputDir); // We will store the parent directory paths to be // examined in the below vector. std::vector<char*> parentDirs; int childCount; char currentPath[MAX_PATH]; FileObject* currentFileObj = m_rootObject; strcpy( currentPath, "/" ); // Split the entries based on '/' and append the // previous directory name to get the full path. pathEntry = strtok (dir,"/"); while(pathEntry != NULL) { if (currentFileObj) { childCount = currentFileObj->GetChildCount(); currentFileObj = currentFileObj->GetChildByName(pathEntry); if (currentFileObj) { HTREEITEM hti = (HTREEITEM)(currentFileObj->GetData()); if (hti) { sprintf(currentPath,"%s%s/", currentPath, pathEntry); pathEntry = strtok (NULL,"/"); continue; } } // Cannot find the child. Check if it is because I have no // information about the child, or that I cannot find the child. if (!currentFileObj) { // If I have child data, but I cannot find the child, then // I will stop here and will not queue the operation. if (childCount) return 1; } } if (!parentDirs.size()) { parentDirs.push_back(SU::strdup(currentPath)); } sprintf(currentPath,"%s%s/", currentPath, pathEntry); parentDirs.push_back(SU::strdup(currentPath)); pathEntry = strtok (NULL,"/"); } // If there is some parent directories to be examined, // remove the last directory because this is same as // the input directory. if (parentDirs.size()) parentDirs.pop_back(); QueueGetDir * dirop = new QueueGetDir(m_hNotify, inputDir, parentDirs); m_mainQueue->AddQueueOp(dirop); return 0; }