From 8a4d03207633e9fdc364aaed82bd167f844679f9 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Fri, 3 Jun 2022 17:47:31 -0500 Subject: Resolve paths while parsing them from the command line. The current directory is a process wide setting that can potentially be changed by any thread. Remove fileutil methods that had equivalent pathutil methods. --- src/burn/engine/core.cpp | 18 ++++++------------ src/burn/engine/logging.cpp | 5 +---- 2 files changed, 7 insertions(+), 16 deletions(-) (limited to 'src/burn') diff --git a/src/burn/engine/core.cpp b/src/burn/engine/core.cpp index 4255fa6b..39836bce 100644 --- a/src/burn/engine/core.cpp +++ b/src/burn/engine/core.cpp @@ -1419,7 +1419,7 @@ extern "C" HRESULT CoreParseCommandLine( ++i; - hr = StrAllocString(&pInternalCommand->sczLogFile, argv[i], 0); + hr = PathExpand(&pInternalCommand->sczLogFile, argv[i], PATH_EXPAND_FULLPATH); ExitOnFailure(hr, "Failed to copy log file path."); } else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, L"?", -1) || @@ -1516,7 +1516,7 @@ extern "C" HRESULT CoreParseCommandLine( } ++i; - hr = StrAllocString(&pInternalCommand->sczOriginalSource, argv[i], 0); + hr = PathExpand(&pInternalCommand->sczOriginalSource, argv[i], PATH_EXPAND_FULLPATH); ExitOnFailure(hr, "Failed to copy last used source."); } else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], -1, BURN_COMMANDLINE_SWITCH_PARENT, -1)) @@ -1547,7 +1547,7 @@ extern "C" HRESULT CoreParseCommandLine( ++i; - hr = StrAllocString(&pInternalCommand->sczLogFile, argv[i], 0); + hr = PathExpand(&pInternalCommand->sczLogFile, argv[i], PATH_EXPAND_FULLPATH); ExitOnFailure(hr, "Failed to copy append log file path."); pInternalCommand->dwLoggingAttributes |= BURN_LOGGING_ATTRIBUTE_APPEND; @@ -1638,7 +1638,7 @@ extern "C" HRESULT CoreParseCommandLine( } else if (L'\0' != wzParam[1]) { - hr = StrAllocString(&pInternalCommand->sczSourceProcessPath, wzParam + 1, 0); + hr = PathExpand(&pInternalCommand->sczSourceProcessPath, wzParam + 1, PATH_EXPAND_FULLPATH); ExitOnFailure(hr, "Failed to copy source process path."); } } @@ -1807,16 +1807,10 @@ extern "C" HRESULT CoreParseCommandLine( fInvalidCommandLine = TRUE; TraceLog(E_INVALIDARG, "Invalid switch: %ls", argv[i]); } - else if (L'\0' == wzParam[1]) - { - // Need to grab the current directory here since this is passed on to other processes. - hr = DirGetCurrent(&pInternalCommand->sczEngineWorkingDirectory); - ExitOnFailure(hr, "Failed to get current directory for custom working directory."); - } else { - hr = StrAllocString(&pInternalCommand->sczEngineWorkingDirectory, wzParam + 1, 0); - ExitOnFailure(hr, "Failed to allocate the custom working directory."); + hr = PathExpand(&pInternalCommand->sczEngineWorkingDirectory, wzParam + 1, PATH_EXPAND_FULLPATH); + ExitOnFailure(hr, "Failed to store the custom working directory."); } } else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, &argv[i][1], lstrlenW(BURN_COMMANDLINE_SWITCH_FILEHANDLE_ATTACHED), BURN_COMMANDLINE_SWITCH_FILEHANDLE_ATTACHED, lstrlenW(BURN_COMMANDLINE_SWITCH_FILEHANDLE_ATTACHED))) diff --git a/src/burn/engine/logging.cpp b/src/burn/engine/logging.cpp index 8e89957b..3a403025 100644 --- a/src/burn/engine/logging.cpp +++ b/src/burn/engine/logging.cpp @@ -84,9 +84,6 @@ extern "C" HRESULT LoggingOpen( { DWORD cRetry = 0; - hr = DirGetCurrent(&sczLoggingBaseFolder); - ExitOnFailure(hr, "Failed to get current directory."); - // Try pretty hard to open the log file when appending. do { @@ -95,7 +92,7 @@ extern "C" HRESULT LoggingOpen( ::Sleep(LOG_OPEN_RETRY_WAIT); } - hr = LogOpen(sczLoggingBaseFolder, pLog->sczPath, NULL, NULL, pLog->dwAttributes & BURN_LOGGING_ATTRIBUTE_APPEND, FALSE, &pLog->sczPath); + hr = LogOpen(NULL, pLog->sczPath, NULL, NULL, pLog->dwAttributes & BURN_LOGGING_ATTRIBUTE_APPEND, FALSE, &pLog->sczPath); if (pLog->dwAttributes & BURN_LOGGING_ATTRIBUTE_APPEND && HRESULT_FROM_WIN32(ERROR_SHARING_VIOLATION) == hr) { ++cRetry; -- cgit v1.2.3-55-g6feb