ReactOS 0.4.15-dev-7924-g5949c20
BtrfsChangeDriveLetter Class Reference

#include <volpropsheet.h>

Collaboration diagram for BtrfsChangeDriveLetter:

Public Member Functions

 BtrfsChangeDriveLetter (HWND hwnd, const wstring_view &fn)
 
void show ()
 
INT_PTR DlgProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 

Private Member Functions

void do_change (HWND hwndDlg)
 

Private Attributes

HWND hwnd
 
wstring fn
 
vector< wchar_tletters
 

Detailed Description

Definition at line 115 of file volpropsheet.h.

Constructor & Destructor Documentation

◆ BtrfsChangeDriveLetter()

BtrfsChangeDriveLetter::BtrfsChangeDriveLetter ( HWND  hwnd,
const wstring_view &  fn 
)
inline

Definition at line 117 of file volpropsheet.h.

117 : hwnd(hwnd), fn(fn) {
118 }
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023

Member Function Documentation

◆ DlgProc()

INT_PTR BtrfsChangeDriveLetter::DlgProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 1526 of file volpropsheet.cpp.

1526 {
1527 try {
1528 switch (uMsg) {
1529 case WM_INITDIALOG:
1530 {
1532
1534
1535 mountmgr mm;
1536 wstring drv;
1537
1538 drv = L"\\DosDevices\\?:";
1539
1540 for (wchar_t l = 'A'; l <= 'Z'; l++) {
1541 bool found = true;
1542
1543 drv[12] = l;
1544
1545 try {
1546 auto v = mm.query_points(drv);
1547
1548 if (v.empty())
1549 found = false;
1550 } catch (const ntstatus_error& ntstatus) {
1551 if (ntstatus.Status == STATUS_OBJECT_NAME_NOT_FOUND)
1552 found = false;
1553 else
1554 throw;
1555 }
1556
1557 if (!found) {
1558 wstring str = L"?:";
1559
1560 str[0] = l;
1562
1563 SendMessageW(cb, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(str.c_str()));
1564 }
1565 }
1566
1567 break;
1568 }
1569
1570 case WM_COMMAND:
1571 switch (HIWORD(wParam)) {
1572 case BN_CLICKED:
1573 switch (LOWORD(wParam)) {
1574 case IDOK:
1575 do_change(hwndDlg);
1576 return true;
1577
1578 case IDCANCEL:
1579 EndDialog(hwndDlg, 0);
1580 return true;
1581 }
1582 break;
1583 }
1584 break;
1585 }
1586 } catch (const exception& e) {
1587 error_message(hwndDlg, e.what());
1588 }
1589
1590 return false;
1591}
r l[0]
Definition: byte_order.h:168
void do_change(HWND hwndDlg)
vector< wchar_t > letters
Definition: volpropsheet.h:128
std::vector< mountmgr_point > query_points(const std::wstring_view &symlink=L"", const std::wstring_view &unique_id=L"", const std::wstring_view &device_name=L"") const
NTSTATUS Status
Definition: shellext.h:385
WPARAM wParam
Definition: combotst.c:138
void error_message(HWND hwnd, const char *msg)
Definition: main.cpp:783
#define IDC_DRIVE_LETTER_COMBO
Definition: resource.h:338
const GLdouble * v
Definition: gl.h:2040
#define e
Definition: ke_i.h:82
static HMODULE MODULEINFO DWORD cb
Definition: module.c:33
#define L(x)
Definition: ntvdm.h:50
#define LOWORD(l)
Definition: pedump.c:82
const WCHAR * str
void push_back(const _Tp &__x=_STLP_DEFAULT_CONSTRUCTED(_Tp))
Definition: _vector.h:379
#define HIWORD(l)
Definition: typedefs.h:247
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
LONG_PTR LPARAM
Definition: windef.h:208
#define IDCANCEL
Definition: winuser.h:831
#define WM_COMMAND
Definition: winuser.h:1740
#define CB_RESETCONTENT
Definition: winuser.h:1959
#define WM_INITDIALOG
Definition: winuser.h:1739
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDOK
Definition: winuser.h:830
#define CB_ADDSTRING
Definition: winuser.h:1936
#define BN_CLICKED
Definition: winuser.h:1925
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)

Referenced by dlg_proc().

◆ do_change()

void BtrfsChangeDriveLetter::do_change ( HWND  hwndDlg)
private

Definition at line 1476 of file volpropsheet.cpp.

1476 {
1477 unsigned int sel = (unsigned int)SendDlgItemMessageW(hwndDlg, IDC_DRIVE_LETTER_COMBO, CB_GETCURSEL, 0, 0);
1478
1479 if (sel < letters.size()) {
1480 wstring dd;
1481
1482 if (fn.length() == 3 && fn[1] == L':' && fn[2] == L'\\') {
1483 dd = L"\\DosDevices\\?:";
1484
1485 dd[12] = fn[0];
1486 } else
1487#ifndef __REACTOS__
1488 throw runtime_error("Volume path was not root of drive.");
1489#else
1490 error_message(nullptr, "Volume path was not root of drive.");
1491#endif
1492
1493 mountmgr mm;
1494 wstring dev_name;
1495
1496 {
1497 auto v = mm.query_points(dd);
1498
1499 if (v.empty())
1500#ifndef __REACTOS__
1501 throw runtime_error("Error finding device name.");
1502#else
1503 error_message(nullptr, "Error finding device name.");
1504#endif
1505
1506 dev_name = v[0].device_name;
1507 }
1508
1509 wstring new_dd = L"\\DosDevices\\?:";
1510 new_dd[12] = letters[sel];
1511
1512 mm.delete_points(dd);
1513
1514 try {
1515 mm.create_point(new_dd, dev_name);
1516 } catch (...) {
1517 // if fails, try to recreate old symlink, so we're not left with no drive letter at all
1518 mm.create_point(dd, dev_name);
1519 throw;
1520 }
1521 }
1522
1523 EndDialog(hwndDlg, 1);
1524}
void create_point(const std::wstring_view &symlink, const std::wstring_view &device) const
void delete_points(const std::wstring_view &symlink, const std::wstring_view &unique_id=L"", const std::wstring_view &device_name=L"") const
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
const char * dev_name(int device)
Definition: wave.c:211
size_type size() const
Definition: _vector.h:192
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define CB_GETCURSEL
Definition: winuser.h:1943

Referenced by DlgProc().

◆ show()

void BtrfsChangeDriveLetter::show ( )

Definition at line 1605 of file volpropsheet.cpp.

1605 {
1607}
#define IDD_DRIVE_LETTER
Definition: resource.h:95
static INT_PTR __stdcall dlg_proc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)

Referenced by ShowChangeDriveLetterW().

Member Data Documentation

◆ fn

wstring BtrfsChangeDriveLetter::fn
private

Definition at line 127 of file volpropsheet.h.

Referenced by do_change().

◆ hwnd

HWND BtrfsChangeDriveLetter::hwnd
private

Definition at line 126 of file volpropsheet.h.

◆ letters

vector<wchar_t> BtrfsChangeDriveLetter::letters
private

Definition at line 128 of file volpropsheet.h.

Referenced by DlgProc(), and do_change().


The documentation for this class was generated from the following files: