mirror of
https://github.com/reactos/reactos.git
synced 2025-08-07 05:52:57 +00:00
[DISKPART] Support quoted options in commands
This commit is contained in:
parent
4a305266e6
commit
3ca37d6eaf
3 changed files with 83 additions and 2 deletions
|
@ -78,3 +78,71 @@ RoundingDivide(
|
|||
{
|
||||
return (Dividend + Divisor / 2) / Divisor;
|
||||
}
|
||||
|
||||
|
||||
PWSTR
|
||||
DuplicateQuotedString(
|
||||
_In_ PWSTR pszInString)
|
||||
{
|
||||
PWSTR pszOutString = NULL;
|
||||
PWSTR pStart, pEnd;
|
||||
INT nLength;
|
||||
|
||||
if ((pszInString == NULL) || (pszInString[0] == UNICODE_NULL))
|
||||
return NULL;
|
||||
|
||||
if (pszInString[0] == L'"')
|
||||
{
|
||||
if (pszInString[1] == UNICODE_NULL)
|
||||
return NULL;
|
||||
|
||||
pStart = &pszInString[1];
|
||||
pEnd = wcschr(pStart, '"');
|
||||
if (pEnd == NULL)
|
||||
{
|
||||
nLength = wcslen(pStart);
|
||||
}
|
||||
else
|
||||
{
|
||||
nLength = (pEnd - pStart);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pStart = pszInString;
|
||||
nLength = wcslen(pStart);
|
||||
}
|
||||
|
||||
pszOutString = RtlAllocateHeap(RtlGetProcessHeap(),
|
||||
HEAP_ZERO_MEMORY,
|
||||
(nLength + 1) * sizeof(WCHAR));
|
||||
if (pszOutString == NULL)
|
||||
return NULL;
|
||||
|
||||
wcsncpy(pszOutString, pStart, nLength);
|
||||
|
||||
return pszOutString;
|
||||
}
|
||||
|
||||
|
||||
PWSTR
|
||||
DuplicateString(
|
||||
_In_ PWSTR pszInString)
|
||||
{
|
||||
PWSTR pszOutString = NULL;
|
||||
INT nLength;
|
||||
|
||||
if ((pszInString == NULL) || (pszInString[0] == UNICODE_NULL))
|
||||
return NULL;
|
||||
|
||||
nLength = wcslen(pszInString);
|
||||
pszOutString = RtlAllocateHeap(RtlGetProcessHeap(),
|
||||
HEAP_ZERO_MEMORY,
|
||||
(nLength + 1) * sizeof(WCHAR));
|
||||
if (pszOutString == NULL)
|
||||
return NULL;
|
||||
|
||||
wcscpy(pszOutString, pszInString);
|
||||
|
||||
return pszOutString;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue