Void DeleteFolder(LPWSTR lpPath, LPWIN32_FIND_DATAW pWfd) { LPWSTR lpEnd; HANDLE hFind; if (GetFileAttributesW(lpPath) == -1) return; lpEnd = lpPath + lstrlenW(lpPath); lstrcpyW(lpEnd, L"\\*.*"); hFind = FindFirstFileW(lpPath, pWfd); if (hFind != INVALID_HANDLE_VALUE) { do { if (IsParentDirectory(pWfd->cFileName)) continue; lstrcpyW(lpEnd + 1, pWfd->cFileName); if (pWfd->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { DeleteFolder(lpPath, pWfd); } else { _DeleteFile(lpPath); } } while (FindNextFileW(hFind, pWfd)); FindClose(hFind); } *lpEnd = 0; }
BOOL CFileManip::DelTree(LPCTSTR lpSource, BOOL bHidePrompt) { TCHAR szSource[MAX_PATH + 2] = _T(""); ::_tcsncpy(szSource, lpSource, MAX_PATH); SHFILEOPSTRUCT fs; ::memset(&fs, 0, sizeof(SHFILEOPSTRUCT)); fs.pFrom = szSource; fs.wFunc = FO_DELETE; if (bHidePrompt) fs.fFlags |= (FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR); // If lpSource or any of its subdirectories is the current // directory, we need to browse backward until the current // directory is parent of lpSource, otherwise operation will // fail. TCHAR szCurDir[MAX_PATH + 1] = _T(""); ::GetCurrentDirectory(MAX_PATH, szCurDir); // Keeps travelling backward until current directory becomes parent // or root directory is reached. BOOL bNotRoot = TRUE; while (bNotRoot && !IsParentDirectory(szCurDir, szSource)) { bNotRoot = CdDotDot(szCurDir); } return (::SHFileOperation(&fs) == 0); }
void ForceInline main2(int argc, WChar **argv) { LPWSTR lpFileName; WCHAR szPath[MAX_PATH]; HANDLE hFind; WIN32_FIND_DATAW wfd; // setlocale(LC_CTYPE, ""); for (int i = 1; i != argc; ++i) { hFind = FindFirstFileW(argv[i], &wfd); if (hFind == INVALID_HANDLE_VALUE) continue; lstrcpyW(szPath, argv[i]); lpFileName = findnamew(szPath); do { if (IsParentDirectory(wfd.cFileName)) continue; lstrcpyW(lpFileName, wfd.cFileName); if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) DeleteFolder(szPath, &wfd); else _DeleteFile(szPath); } while (FindNextFileW(hFind, &wfd)); FindClose(hFind); } }
bool Panel::ProcessMouseDrag(const MOUSE_EVENT_RECORD *MouseEvent) { if (DragX!=-1) { if (!(MouseEvent->dwButtonState & MOUSE_ANY_BUTTON_PRESSED)) { EndDrag(); if (!MouseEvent->dwEventFlags && SrcDragPanel!=this) { MoveToMouse(MouseEvent); Redraw(); SrcDragPanel->ProcessKey(Manager::Key(DragMove ? KEY_DRAGMOVE:KEY_DRAGCOPY)); } return true; } if (MouseEvent->dwMousePosition.Y<=m_Y1 || MouseEvent->dwMousePosition.Y>=m_Y2 || !Parent()->GetAnotherPanel(SrcDragPanel)->IsVisible()) { EndDrag(); return true; } if (MouseEvent->dwButtonState & RIGHTMOST_BUTTON_PRESSED && !MouseEvent->dwEventFlags) DragMove=!DragMove; if (MouseEvent->dwButtonState & FROM_LEFT_1ST_BUTTON_PRESSED) { if ((abs(MouseEvent->dwMousePosition.X-DragX)>15 || SrcDragPanel!=this) && !m_ModalMode) { if (SrcDragPanel->GetSelCount()==1 && !DragSaveScr) { SrcDragPanel->GoToFile(strDragName); SrcDragPanel->Show(); } DragMessage(MouseEvent->dwMousePosition.X,MouseEvent->dwMousePosition.Y,DragMove); return true; } else { DragSaveScr.reset(); } } } if (MouseEvent->dwButtonState & FROM_LEFT_1ST_BUTTON_PRESSED && !MouseEvent->dwEventFlags && m_X2 - m_X1<ScrX) { MoveToMouse(MouseEvent); os::fs::find_data Data; if (!get_first_selected(Data)) return false; strDragName = Data.FileName; if (!IsParentDirectory(Data)) { SrcDragPanel=this; DragX=MouseEvent->dwMousePosition.X; DragY=MouseEvent->dwMousePosition.Y; DragMove = IntKeyState.ShiftPressed(); } } return false; }