ReactOS  0.4.14-dev-815-ge410a12
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  }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22

Member Function Documentation

◆ DlgProc()

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

Definition at line 1524 of file volpropsheet.cpp.

1524  {
1525  try {
1526  switch (uMsg) {
1527  case WM_INITDIALOG:
1528  {
1530 
1532 
1533  mountmgr mm;
1534  wstring drv;
1535 
1536  drv = L"\\DosDevices\\?:";
1537 
1538  for (wchar_t l = 'A'; l <= 'Z'; l++) {
1539  bool found = true;
1540 
1541  drv[12] = l;
1542 
1543  try {
1544  auto v = mm.query_points(drv);
1545 
1546  if (v.empty())
1547  found = false;
1548  } catch (const ntstatus_error& ntstatus) {
1549  if (ntstatus.Status == STATUS_OBJECT_NAME_NOT_FOUND)
1550  found = false;
1551  else
1552  throw;
1553  }
1554 
1555  if (!found) {
1556  wstring str = L"?:";
1557 
1558  str[0] = l;
1559  letters.push_back(l);
1560 
1561  SendMessageW(cb, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(str.c_str()));
1562  }
1563  }
1564 
1565  break;
1566  }
1567 
1568  case WM_COMMAND:
1569  switch (HIWORD(wParam)) {
1570  case BN_CLICKED:
1571  switch (LOWORD(wParam)) {
1572  case IDOK:
1573  do_change(hwndDlg);
1574  return true;
1575 
1576  case IDCANCEL:
1577  EndDialog(hwndDlg, 0);
1578  return true;
1579  }
1580  break;
1581  }
1582  break;
1583  }
1584  } catch (const exception& e) {
1585  error_message(hwndDlg, e.what());
1586  }
1587 
1588  return false;
1589 }
#define IDOK
Definition: winuser.h:824
void do_change(HWND hwndDlg)
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
void error_message(HWND hwnd, const char *msg)
Definition: main.cpp:785
#define e
Definition: ke_i.h:82
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
#define CB_ADDSTRING
Definition: winuser.h:1918
const WCHAR * str
#define CB_RESETCONTENT
Definition: winuser.h:1941
r l[0]
Definition: byte_order.h:167
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
void push_back(const _Tp &__x=_STLP_DEFAULT_CONSTRUCTED(_Tp))
Definition: _vector.h:379
static const NTSTATUS STATUS_OBJECT_NAME_NOT_FOUND
#define BN_CLICKED
Definition: winuser.h:1907
#define IDC_DRIVE_LETTER_COMBO
Definition: resource.h:334
static const WCHAR L[]
Definition: oid.c:1250
vector< wchar_t > letters
Definition: volpropsheet.h:128
#define WM_COMMAND
Definition: winuser.h:1722
const GLdouble * v
Definition: gl.h:2040
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static HMODULE MODULEINFO DWORD cb
Definition: module.c:32
#define HIWORD(l)
Definition: typedefs.h:246
NTSTATUS Status
Definition: shellext.h:385
#define IDCANCEL
Definition: winuser.h:825
#define WM_INITDIALOG
Definition: winuser.h:1721
#define LOWORD(l)
Definition: pedump.c:82

Referenced by show().

◆ do_change()

void BtrfsChangeDriveLetter::do_change ( HWND  hwndDlg)
private

Definition at line 1474 of file volpropsheet.cpp.

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

Referenced by DlgProc().

◆ show()

void BtrfsChangeDriveLetter::show ( void  )

Definition at line 1606 of file volpropsheet.cpp.

1606  {
1607 #ifndef __REACTOS__
1609  BtrfsChangeDriveLetter* bcdl;
1610 
1611  if (uMsg == WM_INITDIALOG) {
1613  bcdl = (BtrfsChangeDriveLetter*)lParam;
1614  } else
1616 
1617  return bcdl->DlgProc(hwndDlg, uMsg, wParam, lParam);
1618  }, (LPARAM)this);
1619 #else
1620  DialogBoxParamW(module, MAKEINTRESOURCEW(IDD_DRIVE_LETTER), hwnd, VolPropSheetDlgproc, (LPARAM)this);
1621 #endif
1622 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
UINT_PTR WPARAM
Definition: windef.h:207
#define SetWindowLongPtr
Definition: treelist.c:70
WPARAM wParam
Definition: combotst.c:138
#define GWLP_USERDATA
Definition: treelist.c:63
LONG_PTR LPARAM
Definition: windef.h:208
#define IDD_DRIVE_LETTER
Definition: resource.h:95
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
unsigned int UINT
Definition: ndis.h:50
INT_PTR DlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define GetWindowLongPtr
Definition: treelist.c:73
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139

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: