void DirectoryTree::AddChildren(const wxTreeItemId& tid) { if(!tid.IsOk()) { wxLogDebug(wxT("DirectoryTree::AddChildren(): invalid wxTreeItemId %u"), (int) tid); return; } wxString sPath; bool bGotPath = GetItemPath(tid, sPath); if(!bGotPath) { wxLogDebug(wxT("DirectoryTree::AddChildren(): GetItemPath(%u) returned \"\""), (int) tid); return; } wxLogTrace(DIRECTORYTREE_EVENTS, wxT("AddChildren('%s')"), sPath.c_str()); DirectoryTreeItem * dti = (DirectoryTreeItem *) GetItemData(tid); if(dti->IsPopulated()) return; // Tell the tree to stop (falsely) showing the button... SetItemHasChildren(tid, false); dti->SetIsPopulated(); // Can we enter this directory? bool bCanExecute = psn.CanExecute(sPath); if(!bCanExecute) { wxLogDebug(wxT("DirectoryTree::AddChildren(): Cannot enter directory '%s'"), sPath.c_str()); return; } // Enumerate sub-directories wxLogTrace(DIRECTORYTREE_EVENTS, wxT("sPath: %s"), sPath.c_str()); DirectoryEntryArray dea(desFILENAME, 0, m_bShowHidden); dea.AddDirectories(sPath); dea.Sort(); // Add them to the tree int nCount = dea.GetCount(); for(int i = 0; i < nCount; i++) { const DirectoryEntry * dre = dea.GetItem(i); wxString sPathName = dre->GetPathName(); wxTreeItemId tidChild = AddChild(tid, sPathName); } }
bool ResourceManager::Activate(const wxString& sPathName) { wxString sFileType = GetFileType(sPathName); if(sFileType.IsEmpty()) return false; // We run executables if we have the necessary permissions wxFileType2 mmt = LoadFileType(sFileType); if(mmt.IsExecutable()) { bool bCanExecute = psn.CanExecute(sPathName); if(bCanExecute) { wxString sCommand = wxString::Format ( wxT("\"%s\""), sPathName.c_str() ); wxExecute(sPathName); return true; } else return false; } wxString sDefaultCommand = mmt.GetDefaultCommand(); if(sDefaultCommand.IsEmpty()) return false; wxString sCommand = wxString::Format ( wxT("%s \"%s\""), sDefaultCommand.c_str(), sPathName.c_str() ); wxExecute(sCommand); return true; }