mirror of
https://github.com/QuasarApp/installer-framework.git
synced 2025-04-27 06:04:30 +00:00
Fix CreateLink operation destination string formatting on Windows
- Fix string formatting syntax in createJunction() method. - Calculate destination directory string length in bytes rather than characters count. - Make minor alterations to operation usage documentation. Task-number: QTIFW-1443 Change-Id: Ia7f6525c865a3e8a6da5376059111c1ef87353ac Reviewed-by: Katja Marttila <katja.marttila@qt.io>
This commit is contained in:
parent
63723d0d74
commit
62eeab668c
@ -205,8 +205,8 @@
|
||||
\row
|
||||
\li CreateLink
|
||||
\li "CreateLink" \c linkPath \c targetPath
|
||||
\li Creates a link from the location specified by \c linkPath to
|
||||
the location specified by \c targetPath.
|
||||
\li Creates a link in the location specified by \c linkPath that
|
||||
points to the location specified by \c targetPath.
|
||||
\row
|
||||
\li CreateLocalRepository
|
||||
\li "CreateLocalRepository" \c binaryPath \c repoPath
|
||||
|
@ -146,9 +146,12 @@ Link createJunction(const QString &linkPath, const QString &targetPath)
|
||||
return Link(linkPath);
|
||||
}
|
||||
|
||||
const QString szDestDir = QString::fromLatin1("\\??\\").arg(targetPath).replace(QLatin1Char('/'),
|
||||
const QString szDestDir = QString::fromLatin1("\\??\\%1").arg(targetPath).replace(QLatin1Char('/'),
|
||||
QLatin1Char('\\'));
|
||||
|
||||
// Get string length in bytes, not in characters count
|
||||
const size_t destDirBytes = szDestDir.size() * sizeof(ushort);
|
||||
|
||||
// Allocates a block of memory for an array of num elements(1) and initializes all its bits to zero.
|
||||
REPARSE_DATA_BUFFER* reparseStructData = (REPARSE_DATA_BUFFER*)calloc(1,
|
||||
MAXIMUM_REPARSE_DATA_BUFFER_SIZE);
|
||||
@ -156,11 +159,11 @@ Link createJunction(const QString &linkPath, const QString &targetPath)
|
||||
reparseStructData->ReparseTag = IO_REPARSE_TAG_MOUNT_POINT;
|
||||
reparseStructData->MountPointReparseBuffer.PrintNameLength = 0;
|
||||
reparseStructData->MountPointReparseBuffer.SubstituteNameOffset = 0;
|
||||
reparseStructData->MountPointReparseBuffer.SubstituteNameLength = szDestDir.length();
|
||||
reparseStructData->MountPointReparseBuffer.PrintNameOffset = szDestDir.length() + sizeof(WCHAR);
|
||||
reparseStructData->MountPointReparseBuffer.SubstituteNameLength = destDirBytes;
|
||||
reparseStructData->MountPointReparseBuffer.PrintNameOffset = destDirBytes + sizeof(WCHAR);
|
||||
|
||||
uint spaceAfterGeneralData = sizeof(USHORT) * 5 + sizeof(WCHAR); //should be 12
|
||||
reparseStructData->ReparseDataLength = szDestDir.length() + spaceAfterGeneralData;
|
||||
reparseStructData->ReparseDataLength = destDirBytes + spaceAfterGeneralData;
|
||||
|
||||
#ifndef Q_CC_MINGW
|
||||
StringCchCopy(reparseStructData->MountPointReparseBuffer.PathBuffer, 1024, (wchar_t*)szDestDir.utf16());
|
||||
|
Loading…
x
Reference in New Issue
Block a user