Skip to content

Commit

Permalink
RemoveFolderEx: Remove a folder recursively. Differs from WixUtilExte…
Browse files Browse the repository at this point in the history
…nsion's RemoveFolderEx in proper handling of reparse points (symbolic links, mount volumes, etc.)

Reparse points are deleted before RemoveFiles action. On rollback, the reparse points are restored
Worksaround Windows Installer bugous handling of reparse points- such as deleting the target of symbolic link files, or keeping directory symbolic link if their target contains files
  • Loading branch information
nirbar committed Nov 14, 2024
1 parent aa09c1b commit 7119c58
Show file tree
Hide file tree
Showing 24 changed files with 1,245 additions and 122 deletions.
26 changes: 23 additions & 3 deletions src/CaCommon/WixString.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class CWixString
return pS;
}

HRESULT Copy(const CWixString &other)
HRESULT Copy(const CWixString& other)
{
HRESULT hr = S_OK;

Expand Down Expand Up @@ -208,7 +208,7 @@ class CWixString
ExitOnNull((dwStart < StrLen()), hr, E_INVALIDSTATE, "Substring start index is out of range");

szOld = Detach();

hr = Copy(szOld + dwStart, dwLength);
ExitOnFailure(hr, "Failed to copy string");

Expand Down Expand Up @@ -259,7 +259,7 @@ class CWixString
LPWSTR szObfuscated = nullptr;
LPWSTR szMsiHiddenProperties = nullptr;
LPWSTR szHideMe = nullptr;

Release();

hr = StrAllocString(&szStripped, szFormat, 0);
Expand Down Expand Up @@ -384,6 +384,26 @@ class CWixString
return hr;
}

// Remove characters from the left
void RemoveLeft(DWORD dwCount)
{
DWORD dwNewLen = 0;
DWORD i = 0;

if (dwCount >= StrLen())
{
Release();
return;
}

dwNewLen = StrLen() - dwCount;
for (i = 0; i < dwNewLen; ++i)
{
_pS[i] = _pS[i + dwCount];
}
_pS[i] = NULL;
}

#pragma region Tokenize

HRESULT Tokenize(LPCWSTR delimiters, LPCWSTR* firstToken)
Expand Down
6 changes: 6 additions & 0 deletions src/PanelSwCustomActions/CommonDeferred.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "XslTransform.h"
#include "RestartLocalResources.h"
#include "ConcatFiles.h"
#include "ReparsePoint.h"

// ReceiverToExecutorFunc implementation.
HRESULT ReceiverToExecutor(LPCSTR szReceiver, CDeferredActionBase** ppExecutor)
Expand Down Expand Up @@ -90,6 +91,11 @@ HRESULT ReceiverToExecutor(LPCSTR szReceiver, CDeferredActionBase** ppExecutor)
WcaLog(LOGLEVEL::LOGMSG_VERBOSE, "Creating ConcatFiles handler");
(*ppExecutor) = new CConcatFiles();
}
else if (0 == ::strcmp(szReceiver, "CReparsePoint"))
{
WcaLog(LOGLEVEL::LOGMSG_VERBOSE, "Creating ReparsePoint handler");
(*ppExecutor) = new CReparsePoint();
}
else
{
hr = E_INVALIDARG;
Expand Down
Loading

0 comments on commit 7119c58

Please sign in to comment.