ReactOS  0.4.15-dev-509-g96a357b
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 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;
1561  letters.push_back(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 }
#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:338
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 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 >= 0 && 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 }
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:338
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 1608 of file volpropsheet.cpp.

1608  {
1609 #ifndef __REACTOS__
1611  BtrfsChangeDriveLetter* bcdl;
1612 
1613  if (uMsg == WM_INITDIALOG) {
1615  bcdl = (BtrfsChangeDriveLetter*)lParam;
1616  } else
1618 
1619  return bcdl->DlgProc(hwndDlg, uMsg, wParam, lParam);
1620  }, (LPARAM)this);
1621 #else
1622  DialogBoxParamW(module, MAKEINTRESOURCEW(IDD_DRIVE_LETTER), hwnd, VolPropSheetDlgproc, (LPARAM)this);
1623 #endif
1624 }
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: