* Shell Library Functions
*
* Copyright 2005 Johannes Anderwald
+ * Copyright 2017 Katayama Hirofumi MZ
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
else
ClusterSize = 2048;
}
+ else if (!wcsicmp(szFs, L"EXT2"))
+ {
+ // auto block size calculation
+ ClusterSize = 0;
+ }
+ else if (!wcsicmp(szFs, L"BtrFS"))
+ {
+ // auto block size calculation
+ ClusterSize = 0;
+ }
else
return FALSE;
UINT DriveType;
} DRIVE_PROP_PAGE;
-BOOL
-SH_ShowDriveProperties(WCHAR *pwszDrive, LPCITEMIDLIST pidlFolder, LPCITEMIDLIST *apidl)
+HRESULT
+SH_ShowDriveProperties(WCHAR *pwszDrive, LPCITEMIDLIST pidlFolder, PCUITEMID_CHILD_ARRAY apidl)
{
HPSXA hpsx = NULL;
HPROPSHEETPAGE hpsp[MAX_PROPERTY_SHEET_PAGE];
PROPSHEETHEADERW psh;
CComObject<CDrvDefExt> *pDrvDefExt = NULL;
-
+ WCHAR wszName[256];
+
ZeroMemory(&psh, sizeof(PROPSHEETHEADERW));
psh.dwSize = sizeof(PROPSHEETHEADERW);
psh.dwFlags = 0; // FIXME: make it modeless
psh.nStartPage = 0;
psh.phpage = hpsp;
- WCHAR wszName[256];
- if (GetVolumeInformationW(pwszDrive, wszName, sizeof(wszName) / sizeof(WCHAR), NULL, NULL, NULL, NULL, 0))
+ LPITEMIDLIST completePidl = ILCombine(pidlFolder, apidl[0]);
+ if (!completePidl)
+ return E_OUTOFMEMORY;
+
+ if (ILGetDisplayNameExW(NULL, completePidl, wszName, ILGDN_NORMAL))
{
psh.pszCaption = wszName;
psh.dwFlags |= PSH_PROPTITLE;
- if (wszName[0] == UNICODE_NULL)
- {
- /* FIXME: check if disk is a really a local hdd */
- UINT i = LoadStringW(shell32_hInstance, IDS_DRIVE_FIXED, wszName, sizeof(wszName) / sizeof(WCHAR) - 6);
- StringCchPrintf(wszName + i, sizeof(wszName) / sizeof(WCHAR) - i, L" (%s)", pwszDrive);
- }
}
+
+ ILFree(completePidl);
CComPtr<IDataObject> pDataObj;
HRESULT hr = SHCreateDataObject(pidlFolder, 1, apidl, NULL, IID_PPV_ARG(IDataObject, &pDataObj));
SHAddFromPropSheetExtArray(hpsx, (LPFNADDPROPSHEETPAGE)AddPropSheetPageCallback, (LPARAM)&psh);
}
- HWND hwnd = (HWND)PropertySheetW(&psh);
+ // NOTE: Currently property sheet is modal. If we make it modeless, then it returns HWND.
+ INT_PTR ret = PropertySheetW(&psh);
if (hpsx)
SHDestroyPropSheetExtArray(hpsx);
if (pDrvDefExt)
pDrvDefExt->Release();
- if (!hwnd)
- return FALSE;
- return TRUE;
+ if (ret > 0)
+ return S_OK;
+ if (ret == 0)
+ return S_FALSE;
+ return E_FAIL;
}
static VOID
if (SendMessageW(hDlgCtrl, CB_GETLBTEXT, iSelIndex, (LPARAM)wszBuf) == CB_ERR)
return;
- szDrive[0] = pContext->Drive + 'A';
+ szDrive[0] = pContext->Drive + L'A';
if (!GetDiskFreeSpaceExW(szDrive, &FreeBytesAvailableUser, &TotalNumberOfBytes, NULL))
return;
return;
}
- if (LoadStringW(shell32_hInstance, IDS_DEFAULT_CLUSTER_SIZE, wszBuf, sizeof(wszBuf) / sizeof(WCHAR)))
+ if (LoadStringW(shell32_hInstance, IDS_DEFAULT_CLUSTER_SIZE, wszBuf, _countof(wszBuf)))
{
hDlgCtrl = GetDlgItem(hwndDlg, 28680);
SendMessageW(hDlgCtrl, CB_RESETCONTENT, 0, 0);
SendMessageW(hDlgCtrl, CB_SETITEMDATA, lIndex, (LPARAM)ClusterSize);
SendMessageW(hDlgCtrl, CB_SETCURSEL, 0, 0);
}
+
+ SendMessageW(GetDlgItem(hwndDlg, 28675), BM_SETCHECK, BST_UNCHECKED, 0);
+ EnableWindow(GetDlgItem(hwndDlg, 28675), FALSE);
}
else if (!wcsicmp(wszBuf, L"FAT32"))
{
return;
}
- if (LoadStringW(shell32_hInstance, IDS_DEFAULT_CLUSTER_SIZE, wszBuf, sizeof(wszBuf) / sizeof(WCHAR)))
+ if (LoadStringW(shell32_hInstance, IDS_DEFAULT_CLUSTER_SIZE, wszBuf, _countof(wszBuf)))
{
hDlgCtrl = GetDlgItem(hwndDlg, 28680);
SendMessageW(hDlgCtrl, CB_RESETCONTENT, 0, 0);
SendMessageW(hDlgCtrl, CB_SETITEMDATA, lIndex, (LPARAM)ClusterSize);
SendMessageW(hDlgCtrl, CB_SETCURSEL, 0, 0);
}
+
+ SendMessageW(GetDlgItem(hwndDlg, 28675), BM_SETCHECK, BST_UNCHECKED, 0);
+ EnableWindow(GetDlgItem(hwndDlg, 28675), FALSE);
}
else if (!wcsicmp(wszBuf, L"NTFS"))
{
}
hDlgCtrl = GetDlgItem(hwndDlg, 28680);
- if (LoadStringW(shell32_hInstance, IDS_DEFAULT_CLUSTER_SIZE, wszBuf, sizeof(wszBuf) / sizeof(WCHAR)))
+ if (LoadStringW(shell32_hInstance, IDS_DEFAULT_CLUSTER_SIZE, wszBuf, _countof(wszBuf)))
{
SendMessageW(hDlgCtrl, CB_RESETCONTENT, 0, 0);
lIndex = SendMessageW(hDlgCtrl, CB_ADDSTRING, 0, (LPARAM)wszBuf);
for (lIndex = 0; lIndex < 4; lIndex++)
{
TotalNumberOfBytes.QuadPart = ClusterSize;
- if (StrFormatByteSizeW(TotalNumberOfBytes.QuadPart, wszBuf, sizeof(wszBuf) / sizeof(WCHAR)))
+ if (StrFormatByteSizeW(TotalNumberOfBytes.QuadPart, wszBuf, _countof(wszBuf)))
{
lIndex = SendMessageW(hDlgCtrl, CB_ADDSTRING, 0, (LPARAM)wszBuf);
if (lIndex != CB_ERR)
}
ClusterSize *= 2;
}
+
+ EnableWindow(GetDlgItem(hwndDlg, 28675), TRUE);
+ }
+ else if (!wcsicmp(wszBuf, L"EXT2"))
+ {
+ if (!GetDefaultClusterSize(wszBuf, &ClusterSize, &TotalNumberOfBytes))
+ {
+ TRACE("EXT2 is not supported on hdd larger than 32T current %lu\n", TotalNumberOfBytes.QuadPart);
+ SendMessageW(hDlgCtrl, CB_DELETESTRING, iSelIndex, 0);
+ return;
+ }
+
+ if (LoadStringW(shell32_hInstance, IDS_DEFAULT_CLUSTER_SIZE, wszBuf, _countof(wszBuf)))
+ {
+ hDlgCtrl = GetDlgItem(hwndDlg, 28680);
+ SendMessageW(hDlgCtrl, CB_RESETCONTENT, 0, 0);
+ lIndex = SendMessageW(hDlgCtrl, CB_ADDSTRING, 0, (LPARAM)wszBuf);
+ if (lIndex != CB_ERR)
+ SendMessageW(hDlgCtrl, CB_SETITEMDATA, lIndex, (LPARAM)ClusterSize);
+ SendMessageW(hDlgCtrl, CB_SETCURSEL, 0, 0);
+ }
+
+ EnableWindow(GetDlgItem(hwndDlg, 28675), TRUE);
+ }
+ else if (!wcsicmp(wszBuf, L"BtrFS"))
+ {
+ if (!GetDefaultClusterSize(wszBuf, &ClusterSize, &TotalNumberOfBytes))
+ {
+ TRACE("BtrFS is not supported on hdd larger than 16E current %lu\n", TotalNumberOfBytes.QuadPart);
+ SendMessageW(hDlgCtrl, CB_DELETESTRING, iSelIndex, 0);
+ return;
+ }
+
+ if (LoadStringW(shell32_hInstance, IDS_DEFAULT_CLUSTER_SIZE, wszBuf, _countof(wszBuf)))
+ {
+ hDlgCtrl = GetDlgItem(hwndDlg, 28680);
+ SendMessageW(hDlgCtrl, CB_RESETCONTENT, 0, 0);
+ lIndex = SendMessageW(hDlgCtrl, CB_ADDSTRING, 0, (LPARAM)wszBuf);
+ if (lIndex != CB_ERR)
+ SendMessageW(hDlgCtrl, CB_SETITEMDATA, lIndex, (LPARAM)ClusterSize);
+ SendMessageW(hDlgCtrl, CB_SETCURSEL, 0, 0);
+ }
+
+ EnableWindow(GetDlgItem(hwndDlg, 28675), TRUE);
}
else
{
BOOLEAN Latest;
HWND hwndFileSystems;
- cchText = GetWindowTextW(hwndDlg, szText, sizeof(szText) / sizeof(WCHAR) - 1);
+ cchText = GetWindowTextW(hwndDlg, szText, _countof(szText) - 1);
if (cchText < 0)
cchText = 0;
szText[cchText++] = L' ';
szDrive[0] = pContext->Drive + L'A';
- if (GetVolumeInformationW(szDrive, &szText[cchText], (sizeof(szText) / sizeof(WCHAR)) - cchText, NULL, NULL, NULL, szFs, sizeof(szFs) / sizeof(WCHAR)))
+ if (GetVolumeInformationW(szDrive, &szText[cchText], _countof(szText) - cchText, NULL, NULL, NULL, szFs, _countof(szFs)))
{
if (szText[cchText] == UNICODE_NULL)
{
/* load default volume label */
- cchText += LoadStringW(shell32_hInstance, IDS_DRIVE_FIXED, &szText[cchText], (sizeof(szText) / sizeof(WCHAR)) - cchText);
+ cchText += LoadStringW(shell32_hInstance, IDS_DRIVE_FIXED, &szText[cchText], _countof(szText) - cchText);
}
else
{
}
}
- StringCchPrintfW(szText + cchText, _countof(szText) - cchText, L" (%c)", szDrive[0]);
+ StringCchPrintfW(szText + cchText, _countof(szText) - cchText, L" (%c:)", szDrive[0]);
/* set window text */
SetWindowTextW(hwndDlg, szText);
if (GetDiskFreeSpaceExW(szDrive, &FreeBytesAvailableUser, &TotalNumberOfBytes, NULL))
{
- if (StrFormatByteSizeW(TotalNumberOfBytes.QuadPart, szText, sizeof(szText) / sizeof(WCHAR)))
+ if (StrFormatByteSizeW(TotalNumberOfBytes.QuadPart, szText, _countof(szText)))
{
/* add drive capacity */
SendDlgItemMessageW(hwndDlg, 28673, CB_ADDSTRING, 0, (LPARAM)szText);
HWND hDlgCtrl;
BOOL QuickFormat;
DWORD ClusterSize;
+ DWORD DriveType;
+ FMIFS_MEDIA_FLAG MediaFlag = FMIFS_HARDDISK;
/* set volume path */
- szDrive[0] = pContext->Drive;
+ szDrive[0] = pContext->Drive + L'A';
/* get filesystem */
hDlgCtrl = GetDlgItem(hwndDlg, 28677);
return;
}
Length = SendMessageW(hDlgCtrl, CB_GETLBTEXTLEN, iSelIndex, 0);
- if ((int)Length == CB_ERR || Length + 1 > sizeof(szFileSys) / sizeof(WCHAR))
+ if ((int)Length == CB_ERR || Length + 1 > _countof(szFileSys))
{
FIXME("\n");
return;
/* retrieve the file system */
SendMessageW(hDlgCtrl, CB_GETLBTEXT, iSelIndex, (LPARAM)szFileSys);
- szFileSys[(sizeof(szFileSys)/sizeof(WCHAR))-1] = L'\0';
+ szFileSys[_countof(szFileSys)-1] = L'\0';
/* retrieve the volume label */
hDlgCtrl = GetWindow(hwndDlg, 28679);
Length = SendMessageW(hDlgCtrl, WM_GETTEXTLENGTH, 0, 0);
- if (Length + 1 > sizeof(szLabel) / sizeof(WCHAR))
+ if (Length + 1 > _countof(szLabel))
{
FIXME("\n");
return;
}
- SendMessageW(hDlgCtrl, WM_GETTEXT, sizeof(szLabel) / sizeof(WCHAR), (LPARAM)szLabel);
+ SendMessageW(hDlgCtrl, WM_GETTEXT, _countof(szLabel), (LPARAM)szLabel);
szLabel[(sizeof(szLabel)/sizeof(WCHAR))-1] = L'\0';
/* check for quickformat */
*/
FormatDrvDialog = hwndDlg;
+ /* See if the drive is removable or not */
+ DriveType = GetDriveTypeW(szDrive);
+ switch (DriveType)
+ {
+ case DRIVE_UNKNOWN:
+ case DRIVE_REMOTE:
+ case DRIVE_CDROM:
+ case DRIVE_NO_ROOT_DIR:
+ {
+ FIXME("\n");
+ return;
+ }
+
+ case DRIVE_REMOVABLE:
+ MediaFlag = FMIFS_FLOPPY;
+ break;
+
+ case DRIVE_FIXED:
+ case DRIVE_RAMDISK:
+ MediaFlag = FMIFS_HARDDISK;
+ break;
+ }
+
+ /* Format the drive */
FormatEx(szDrive,
- FMIFS_HARDDISK, /* FIXME */
+ MediaFlag,
szFileSys,
szLabel,
QuickFormat,
}
else
{
- pContext->Result = FALSE;
+ pContext->Result = FALSE;
}
}