void CWSFCHomeListCtrl::OnAddNew (void) { // Get WSF/C Home Path CString sPath; if (FALSE == GetFolder (&sPath, "Find WSF/C Home Location.", this->m_hWnd, NULL, NULL)) return; // Validate Path if (true == sPath.IsEmpty ()) return; CString sAxis2XMLFile = sPath; if (sAxis2XMLFile[sAxis2XMLFile.GetLength () - 1] != '\\') sAxis2XMLFile+= "\\"; sAxis2XMLFile+= "axis2.xml"; CFile oAxis2XMLFile; if (FALSE == oAxis2XMLFile.Open (sAxis2XMLFile, CFile::modeRead | CFile::shareDenyNone)) { CString sMessage = "\""; sMessage+= sPath; sMessage+= "\" is not a valid WSF/C home !!!"; AfxMessageBox (sMessage, MB_ICONEXCLAMATION | MB_OK); return; } // Add Path to List Ctrl InsertItem (GetItemCount (), sPath); }
void CFileBrowserListCtrl::OnEndlabeledit(NMHDR* pNMHDR, LRESULT* pResult) { LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR; CEdit *pEdit = GetEditControl(); if (m_LabelEdit && pEdit != NULL) { // if label edit wasn't canceled CString NewName; pEdit->GetWindowText(NewName); // label is new item name int ItemIdx = pDispInfo->item.iItem; CDirItem& item = m_DirList.GetItem(ItemIdx); if (NewName != item.GetName()) { // if name is different CPathStr NewPath(GetFolder()); NewPath.Append(NewName); // make new item path CString OldPath(GetItemPath(ItemIdx)); if (RenameFile(m_hWnd, OldPath, NewPath)) { item.SetName(NewName); // update item name NMFBRENAMEITEM nmri; nmri.pszOldPath = OldPath; nmri.pszNewPath = NewPath; Notify(FBLCN_RENAMEITEM, &nmri); } } } m_LabelEdit = FALSE; *pResult = 0; }
void FolderMonitor::OnFile(const DirectoryChangeNotification& notification) const { anime::Episode episode; auto anime_item = FindAnimeItem(notification, episode); if (!anime_item) return; if (!Meow.IsValidAnimeType(episode) || !Meow.IsValidFileExtension(episode)) return; bool path_available = notification.action != FILE_ACTION_REMOVED; // Set anime folder if (path_available && anime_item->GetFolder().empty()) { ChangeAnimeFolder(*anime_item, episode.folder); } // Set episode availability int lower_bound = anime::GetEpisodeLow(episode); int upper_bound = anime::GetEpisodeHigh(episode); std::wstring path = notification.path + notification.filename.first; for (int number = lower_bound; number <= upper_bound; ++number) { if (anime_item->SetEpisodeAvailability(number, path_available, path)) { LOG(LevelDebug, anime_item->GetTitle() + L" #" + ToWstr(number) + L" is " + (path_available ? L"available." : L"unavailable.")); } } }
void FlatToFoldersProxyModel::HandleChanged (const QModelIndex& idx) { QSet<QString> newTags = QSet<QString>::fromList (idx.data (RoleTags).toStringList ()); if (newTags.isEmpty ()) newTags << QString (); QPersistentModelIndex pidx (idx); QList<FlatTreeItem_ptr> items = Items_.values (pidx); QSet<QString> oldTags; Q_FOREACH (FlatTreeItem_ptr item, items) oldTags << item->Tag_; QSet<QString> added = QSet<QString> (newTags).subtract (oldTags); QSet<QString> removed = QSet<QString> (oldTags).subtract (newTags); QSet<QString> changed = QSet<QString> (newTags).intersect (oldTags); Q_FOREACH (QString ch, changed) { FlatTreeItem_ptr folder = GetFolder (ch); QList<FlatTreeItem_ptr>& c = folder->C_; int findex = Root_->C_.indexOf (folder); QModelIndex fmi = index (findex, 0); for (int i = 0, size = c.size (); i < size; ++i) { if (c.at (i)->Index_ != pidx) continue; emit dataChanged (index (i, 0, fmi), index (i, columnCount () - 1, fmi)); break; } }
int CmFile::GetNames(CStr &nameW, vecS &names) { string dir = GetFolder(nameW); names.clear(); names.reserve(6000); DIR *dp = opendir(_S(dir)); if (dp == NULL){ cout << dir << endl; perror("Cannot open directory"); return EXIT_FAILURE; } struct dirent *dirContent; while ((dirContent = readdir(dp)) != NULL){ if (string(dirContent->d_name)[0] == '.') continue; struct stat st; lstat(dirContent->d_name,&st); if(S_ISREG(st.st_mode)){ cout << string(dirContent->d_name) << " " << st.st_mode << endl; names.push_back(string(dirContent->d_name)); } } closedir(dp); return (int)names.size(); }
void FlatToFoldersProxyModel::RemoveFromTag (const QString& tag, const QPersistentModelIndex& pidx) { FlatTreeItem_ptr folder = GetFolder (tag); QList<FlatTreeItem_ptr>& c = folder->C_; int findex = Root_->C_.indexOf (folder); for (int i = 0, size = c.size (); i < size; ++i) { if (c.at (i)->Index_ != pidx) continue; beginRemoveRows (index (findex, 0), i, i); Items_.remove (pidx, c.at (i)); c.removeAt (i); endRemoveRows (); break; } if (c.isEmpty ()) { beginRemoveRows (QModelIndex (), findex, findex); Root_->C_.removeAt (findex); endRemoveRows (); } }
void COutlook2Ctrl::OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler) { if (m_iSelectedFolder < 0) return; COL2Folder * oFolder = GetFolder(m_iSelectedFolder); for (int i = 0; i < oFolder->m_Items.GetSize(); i++) { COL2Item * pi = (COL2Item *) oFolder->m_Items.GetAt(i); for (int s = 0; s < pi->m_SubItems.GetSize(); s++) { COL2SubItem * ps = (COL2SubItem *) pi->m_SubItems.GetAt(s); if (ps->dwStyle == OCL_SELECT || ps->dwStyle == OCL_RADIO || ps->dwStyle == OCL_CHECK) { COL2CCmdUI pui; pui.pSI = ps; pui.m_nID = ps->lParam; GetOwner()->OnCmdMsg(pui.m_nID, CN_UPDATE_COMMAND_UI, &pui, NULL); if (pui.iRes != ps->iLastStatus && !ps->rcItem.IsRectEmpty()) { InvalidateRect(ps->rcItem); } } } } /* iLastStatus = pui.iRes; TRACE1("%d\n", (int) GetTickCount()); CToolBar b; b.OnUpdateCmdUI(*/ }
void COutlook2Ctrl::SetCurFolder(int f, bool bAnimation) { // hide all subwindows if (m_iSelectedFolder >= 0 && m_iSelectedFolder != f) { for (int f = 0; f < m_Folders.GetSize(); f++) { COL2Folder * pf = (COL2Folder *) m_Folders.GetAt(f); for (int i = 0; i < pf->m_Items.GetSize(); i++) { COL2Item * pi = (COL2Item *) pf->m_Items.GetAt(i); for (int s = 0; s < pi->m_SubItems.GetSize(); s++) { COL2SubItem * ps = (COL2SubItem *) pi->m_SubItems.GetAt(s); if (ps->hHostedWnd) ::ShowWindow(ps->hHostedWnd, SW_HIDE); ps->rcItem.SetRectEmpty(); } } } } if (m_iSelectedFolder != f) { if (bAnimation) AnimateToFolder(f); else { m_iSelectedFolder = f; pLastHilink = NULL; m_csCaption = GetFolder(f)->csName; } Invalidate(); } }
void CFileBrowserListCtrl::OpenParentFolder() { CPathStr path(GetFolder()); if (PathIsRoot(path)) path.Empty(); // show drive list else path.Append(_T("..")); SetFolder(path); }
/** * "파일 풀기"를 눌렀을때 파일을 하나 푸는 함수 */ void CFV_Select::OnMenu_Extract () { int * pIndecies = NULL; /// 선택된 인덱스를 저장 CListBox * plistSel = NULL; /// 리스트 박스용 int nSelCnt = 0; /// 선택된 갯수 BYTE * btBuff = NULL; /// 임시버퍼 CVFS_Manager * pVFS = NULL; /// vfs파일 핸들 FILE * fp = NULL; /// 임시 파일포인터 VFileHandle *pVFH = NULL; /// vfs 파일핸들 CString strText = "", strFileName = "", strDir = ""; /// 스트링, 파일이름, 폴더 if(m_list.GetSelCount () > 0 && (plistSel = GetListBox ()) && (pVFS = ::g_pDlg_Main->GetVFS()) &&::g_pDlg_Main->GetSelectedVfsName ().GetLength () > 0) { /// 파일을 풀 디렉토리를 묻는다 if(GetFolder (&strDir, "파일을 풀 폴더를 선택하세요", GetSafeHwnd (), NULL, NULL)) { /// 인덱스를 저장하기 위해서 메모리를 할당 if((pIndecies = new int[m_list.GetSelCount ()])) { /// 선택된 인덱스들을 가져옴 m_list.GetSelItems (m_list.GetSelCount (), pIndecies); nSelCnt = m_list.GetSelCount (); for(short i = 0; i < nSelCnt; i++) { strText = ""; /// 리스트박스에서 문자열을 가져옴 plistSel->GetText (pIndecies[ nSelCnt - 1 - i ], strText); /// base file명만 불리해서 여기에 다시 저장하고 그리고 파일 생성할 때 사용한다 strFileName = strText; if(strFileName.ReverseFind ('\\') >= 0) { strFileName = strFileName.Right (strFileName.GetLength () - strFileName.ReverseFind ('\\') - 1); } long lFileLength = pVFS->GetFileLength (strText.GetString ()); if(lFileLength >= 0 && (btBuff = new BYTE[ lFileLength ])) { if((pVFH = pVFS->OpenFile (strText.GetString ()))) { vfread (btBuff, sizeof (BYTE), (size_t)lFileLength, pVFH); _fmode = _O_BINARY; if((fp = fopen (strDir + "\\" + strFileName, "w"))) { fwrite (btBuff, sizeof(BYTE), (size_t)lFileLength, fp); fclose (fp); } delete btBuff; pVFS->CloseFile (pVFH); } } } delete pIndecies; } } } }
NS_IMETHODIMP nsNntpUrl::GetFolderCharsetOverride(bool *aCharacterSetOverride) { nsCOMPtr<nsIMsgFolder> folder; nsresult rv = GetFolder(getter_AddRefs(folder)); NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_TRUE(folder, NS_ERROR_FAILURE); rv = folder->GetCharsetOverride(aCharacterSetOverride); NS_ENSURE_SUCCESS(rv, rv); return rv; }
PyObject* pyVault::GetAgeJournalsFolder() { PyObject * result = GetFolder(plVault::kAgeJournalsFolder); // just return an empty node if (!result) result = pyVaultFolderNode::New(nil); return result; }
PyObject* pyVault::GetInviteFolder() { PyObject * result = GetFolder(plVault::kPlayerInviteFolder); // if good then return py object if (result) return result; // otherwise return a None object PYTHON_RETURN_NONE; }
PyObject* pyVault::GetInbox( void ) { PyObject * result = GetFolder(plVault::kInboxFolder); // if good then return py object if (result) return result; // otherwise return a None object PYTHON_RETURN_NONE; }
PyObject* pyVault::GetAvatarClosetFolder() { PyObject * result = GetFolder(plVault::kAvatarClosetFolder); // if good then return py object if (result) return result; // otherwise return a None object PYTHON_RETURN_NONE; }
NS_IMETHODIMP nsNntpUrl::GetFolderCharset(char **aCharacterSet) { nsCOMPtr<nsIMsgFolder> folder; nsresult rv = GetFolder(getter_AddRefs(folder)); // don't assert here. this can happen if there is no message folder // like when we display a news://host/message-id url if (NS_FAILED(rv) || !folder) return rv; nsCString tmpStr; rv = folder->GetCharset(tmpStr); *aCharacterSet = ToNewCString(tmpStr); return rv; }
int CFileBrowserListCtrl::CalcMinColumnWidth(int Col) { enum { BORDER = 6, // minimal spacing; less causes abbreviated text SLACK = 3 // prevents widest item from touching right edge }; CWaitCursor wc; // iterating all items can be slow, especially for file type CClientDC dc(this); HGDIOBJ PrevFont = dc.SelectObject(GetFont()); // must use list control's font int width = 0; CSize sz; CFileInfo FileInfo; CString str; int items = m_DirList.GetCount(); for (int i = 0; i < items; i++) { const CDirItem& item = m_DirList.GetItem(i); switch (Col) { case COL_NAME: str = item.GetName(); break; case COL_SIZE: if (item.IsDir()) continue; FormatSize(item.GetLength(), str); break; case COL_TYPE: // slow if we have many unique file types that aren't cached m_FileInfoCache.GetFileInfo(GetFolder(), item, FileInfo); str = FileInfo.GetTypeName(); break; case COL_MODIFIED: if (item.GetLastWrite() == 0) continue; FormatTime(item.GetLastWrite(), str); break; default: ASSERT(0); } GetTextExtentPoint32(dc.m_hDC, str, str.GetLength(), &sz); if (sz.cx > width) width = sz.cx; } dc.SelectObject(PrevFont); // restore DC's previous font // 25feb09: GetItemRect can fail e.g. if list is empty, in which case we // must avoid adding garbage to column width CRect IconRect; if (GetItemRect(0, IconRect, LVIR_ICON)) width += IconRect.Width(); else // can't get item rect, fall back to system metrics width += GetSystemMetrics(m_ViewType == VTP_ICON ? SM_CXICON : SM_CXSMICON); width += BORDER + SLACK; return(width); }
int CUpdateUtil::GetFolderSymbol(CString& strPath, CString& strReplace) { int retval = 0; CString strCompare = strPath; CString strCompareOriginal = strPath; CString strCompareReplace = ""; if(*m_pbCancel) { retval = UPDATE_ERROR; return retval; } int nStart = strCompare.Find('%'); if(nStart != -1 && nStart == 0) { int nEnd = strCompare.Find('%', nStart+1); if(nEnd != -1) { strReplace = strCompare.Left(nEnd+1); strCompare = strCompare.Left(nEnd); strCompareReplace = strCompare.Right(strCompare.GetLength()-1); retval = GetFolder(strCompareReplace); } else retval = UPDATE_ERROR; } else { int nFindColon = strCompare.Find(':'); if(nFindColon !=-1 && nFindColon == 1) { retval = UPDATE_ERROR; } else { strReplace = "%CurrentDirectory%"; int nFind = strCompare.Find('\\'); if(nFind != -1 && nFind == 0) { strPath = strReplace + strCompareOriginal; } else { strPath = strReplace + "\\" + strCompareOriginal; } retval = UPDATE_CURRENTDIRECTORY; } } return retval; }
void CRecBinViewer::InitInterfaces (void) { if (TRUE == GetFolder2 ()) HeaderFolder2 (); else if (TRUE == GetFolder ()) HeaderFolder (); if (gFolderStateMan.IsIn (CONST_RECYCLEBIN)) gFolderStateMan.LoadState (CONST_RECYCLEBIN, m_State); else gFolderStateMan.SaveState (CONST_RECYCLEBIN, m_State); }
void DPath::SetBaseName(const char *string) { if (IsEmpty()) { SetTo(string); return; } BString temp = GetFolder(); BString ext = GetExtension(); temp << "/" << string << "." << ext; }
W64INT CSaveAsDlg::DoModal() { BuildExtList(); if (m_psFolder != NULL) { m_ofn.lpstrInitialDir = *m_psFolder; m_ofn.Flags |= OFN_NOCHANGEDIR; // otherwise folder stays locked } W64INT retc = CFileDialog::DoModal(); if (retc == IDOK) { if (m_psFolder != NULL) GetFolder(*m_psFolder); } return(retc); }
NS_IMETHODIMP nsMailboxUrl::GetFolderCharset(char ** aCharacterSet) { NS_ENSURE_ARG_POINTER(aCharacterSet); nsCOMPtr<nsIMsgFolder> folder; nsresult rv = GetFolder(getter_AddRefs(folder)); // In cases where a file is not associated with a folder, for // example standalone .eml files, failure is normal. if (NS_FAILED(rv)) return rv; nsCString tmpStr; folder->GetCharset(tmpStr); *aCharacterSet = ToNewCString(tmpStr); return NS_OK; }
void ecChooseRepositoryDialog::OnOK(wxCommandEvent& event) { wxString folder(GetFolder()); if (!wxDirExists(folder)) { wxMessageBox(_("This is not a valid folder.")); return; // Don't Skip so we don't dismiss the dialog } if (FALSE) { wxMessageBox(_("This does not like a valid eCos repository.")); return; // Don't Skip so we don't dismiss the dialog } event.Skip(); }
void InfoBox::GetFolder(BDirectory dir) { int32 c=dir.CountEntries(); BEntry entry; if (c>0) for (int32 i=0; i<c; i++) { dir.GetNextEntry(&entry, true); if (entry.IsDirectory()) { folders++; GetFolder(BDirectory(&entry)); } else files++; } }
void CDirectoriesPropertyPage::OnBrowseInclude() { CString strFolderPath; if (GetFolder(&strFolderPath, _T("Browse for folder to include in search") , this->m_hWnd, NULL, NULL) && !strFolderPath.IsEmpty() ) { // CString Temp; // m_IncludeDirs.GetWindowText(Temp); // if (!Temp.IsEmpty()) Temp += "\r\n"; // Temp += strFolderPath; // m_IncludeDirs.SetWindowText(Temp); m_IncludeDirectoriesList.AddString(strFolderPath); //m_IncDirsList.InsertItem(0,Temp); } }
void CFileBrowserListCtrl::OpenItem(int ItemIdx) { // copy item instead of referencing it, because SetFolder changes m_DirList CDirItem Item = m_DirList.GetItem(ItemIdx); CString ItemPath = GetItemPath(ItemIdx); // grab item path now too if (Item.IsDir()) { // if user selected parent folder and current folder is a root folder if (Item.IsDots() && PathIsRoot(GetFolder())) SetFolder(_T("")); // list drives else SetFolder(ItemPath); } NMFBOPENITEM nmoi; nmoi.pszPath = ItemPath; nmoi.bIsDir = Item.IsDir(); Notify(FBLCN_OPENITEM, &nmoi); }
WString FilePath::GetRelativePathFor(const FilePath& _filePath) { if (fullPath.Length()==0 || _filePath.fullPath.Length()==0 || fullPath[0] != _filePath.fullPath[0]) { return _filePath.fullPath; } #if defined VCZH_MSVC wchar_t buffer[MAX_PATH + 1] = { 0 }; PathRelativePathTo( buffer, fullPath.Buffer(), (IsFolder() ? FILE_ATTRIBUTE_DIRECTORY : 0), _filePath.fullPath.Buffer(), (_filePath.IsFolder() ? FILE_ATTRIBUTE_DIRECTORY : 0) ); return buffer; #elif defined VCZH_GCC collections::List<WString> srcComponents, tgtComponents, resultComponents; GetPathComponents(IsFolder() ? fullPath : GetFolder().GetFullPath(), srcComponents); GetPathComponents(_filePath.fullPath, tgtComponents); int minLength = srcComponents.Count() <= tgtComponents.Count() ? srcComponents.Count() : tgtComponents.Count(); int lastCommonComponent = 0; for(int i = 0; i < minLength; i++) { if(srcComponents[i] == tgtComponents[i]) { lastCommonComponent = i; } else break; } for(int i = lastCommonComponent + 1; i < srcComponents.Count(); i++) { resultComponents.Add(L".."); } for(int i = lastCommonComponent + 1; i < tgtComponents.Count(); i++) { resultComponents.Add(tgtComponents[i]); } return ComponentsToPath(resultComponents); #endif }
void CLibraryView::StartDragging(const CPoint& ptMouse) { CQuickLock oLock( Library.m_pSection ); CPoint ptMiddle( 0, 0 ); HBITMAP pImage = CreateDragImage( ptMouse, ptMiddle ); if ( ! pImage ) return; // Get GUID of parent folder Hashes::Guid oGUID; CLibraryListItem oHit = GetFolder(); if ( oHit.Type == CLibraryListItem::AlbumFolder ) oGUID = ((CAlbumFolder*)oHit)->m_oGUID; CEnvyDataSource::DoDragDrop( m_pSelection, pImage, oGUID, ptMiddle ); }
void CDirectoriesPropertyPage::OnDblclkIncludeDirectoriesList() { CString strFolderPath; CString strOldPath; m_IncludeDirectoriesList.GetText(m_IncludeDirectoriesList.GetCurSel(), strOldPath); if (GetFolder(&strFolderPath, _T("Browse for folder to include in search") , this->m_hWnd, NULL, strOldPath) && !strFolderPath.IsEmpty() ) { int index = m_IncludeDirectoriesList.GetCurSel(); m_IncludeDirectoriesList.InsertString( index, strFolderPath); m_IncludeDirectoriesList.DeleteString( index+1); m_IncludeDirectoriesList.SetCurSel(index); } }
void CSegmentExportDlg::OnBnClickedSegexBrow() { // TODO: Add your control notification handler code here CString strFolderPath; if (GetFolder(&strFolderPath, "Select DICOM files folder", this->m_hWnd, NULL, NULL)){ if (!strFolderPath.IsEmpty()){ strFolderPath = strFolderPath + _T("\\"); UpdateData(FALSE); } else { strFolderPath = _T(".\\"); } m_sDirPath = strFolderPath; UpdateData(FALSE); } }