From cdba28de1ee229369b254c62bc58cf2f001899a3 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Tue, 3 Aug 2021 18:06:54 -0500 Subject: Add argument and policy setting to set Burn's base working directory. Fixes #5856 --- src/libs/dutil/WixToolset.DUtil/pathutil.cpp | 102 --------------------------- 1 file changed, 102 deletions(-) (limited to 'src/libs/dutil/WixToolset.DUtil/pathutil.cpp') diff --git a/src/libs/dutil/WixToolset.DUtil/pathutil.cpp b/src/libs/dutil/WixToolset.DUtil/pathutil.cpp index 5fad519b..7bac8ac3 100644 --- a/src/libs/dutil/WixToolset.DUtil/pathutil.cpp +++ b/src/libs/dutil/WixToolset.DUtil/pathutil.cpp @@ -21,108 +21,6 @@ #define PATH_GOOD_ENOUGH 64 -DAPI_(HRESULT) PathCommandLineAppend( - __deref_inout_z LPWSTR* psczCommandLine, - __in_z LPCWSTR wzArgument - ) -{ - HRESULT hr = S_OK; - LPWSTR sczQuotedArg = NULL; - BOOL fRequiresQuoting = FALSE; - DWORD dwMaxEscapedSize = 0; - - // Loop through the argument determining if it needs to be quoted and what the maximum - // size would be if there are escape characters required. - for (LPCWSTR pwz = wzArgument; *pwz; ++pwz) - { - // Arguments with whitespace need quoting. - if (L' ' == *pwz || L'\t' == *pwz || L'\n' == *pwz || L'\v' == *pwz) - { - fRequiresQuoting = TRUE; - } - else if (L'"' == *pwz) // quotes need quoting and sometimes escaping. - { - fRequiresQuoting = TRUE; - ++dwMaxEscapedSize; - } - else if (L'\\' == *pwz) // some backslashes need escaping, so we'll count them all to make sure there is room. - { - ++dwMaxEscapedSize; - } - - ++dwMaxEscapedSize; - } - - // If we found anything in the argument that requires our argument to be quoted - if (fRequiresQuoting) - { - hr = StrAlloc(&sczQuotedArg, dwMaxEscapedSize + 3); // plus three for the start and end quote plus null terminator. - PathExitOnFailure(hr, "Failed to allocate argument to be quoted."); - - LPCWSTR pwz = wzArgument; - LPWSTR pwzQuoted = sczQuotedArg; - - *pwzQuoted = L'"'; - ++pwzQuoted; - while (*pwz) - { - DWORD dwBackslashes = 0; - while (L'\\' == *pwz) - { - ++dwBackslashes; - ++pwz; - } - - // Escape all backslashes at the end of the string. - if (!*pwz) - { - dwBackslashes *= 2; - } - else if (L'"' == *pwz) // escape all backslashes before the quote and escape the quote itself. - { - dwBackslashes = dwBackslashes * 2 + 1; - } - // the backslashes don't have to be escaped. - - // Add the appropriate number of backslashes - for (DWORD i = 0; i < dwBackslashes; ++i) - { - *pwzQuoted = L'\\'; - ++pwzQuoted; - } - - // If there is a character, add it after all the escaped backslashes - if (*pwz) - { - *pwzQuoted = *pwz; - ++pwz; - ++pwzQuoted; - } - } - - *pwzQuoted = L'"'; - ++pwzQuoted; - *pwzQuoted = L'\0'; // ensure the arg is null terminated. - } - - // If there is already data in the command line, append a space before appending the - // argument. - if (*psczCommandLine && **psczCommandLine) - { - hr = StrAllocConcat(psczCommandLine, L" ", 0); - PathExitOnFailure(hr, "Failed to append space to command line with existing data."); - } - - hr = StrAllocConcat(psczCommandLine, sczQuotedArg ? sczQuotedArg : wzArgument, 0); - PathExitOnFailure(hr, "Failed to copy command line argument."); - -LExit: - ReleaseStr(sczQuotedArg); - - return hr; -} - - DAPI_(LPWSTR) PathFile( __in_z LPCWSTR wzPath ) -- cgit v1.2.3-55-g6feb