| From 74f9bd294505a878d4c991daa2671d530a263723 Mon Sep 17 00:00:00 2001 |
| From: Johannes Schindelin <johannes.schindelin@gmx.de> |
| Date: Wed, 4 Dec 2019 21:40:01 +0100 |
| Subject: test-drop-caches: use `has_dos_drive_prefix()` |
| |
| This is a companion patch to 'mingw: handle `subst`-ed "DOS drives"': |
| use the DOS drive prefix handling that is already provided by |
| `compat/mingw.c` (and which just learned to handle non-alphabetical |
| "drive letters"). |
| |
| Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> |
| (cherry picked from commit 68440496c77c6d3a606537c78ea4b62eb895a64a) |
| Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> |
| --- |
| t/helper/test-drop-caches.c | 11 +++++++---- |
| 1 file changed, 7 insertions(+), 4 deletions(-) |
| |
| diff --git a/t/helper/test-drop-caches.c b/t/helper/test-drop-caches.c |
| index f65e301f9d..7b4278462b 100644 |
| --- a/t/helper/test-drop-caches.c |
| +++ b/t/helper/test-drop-caches.c |
| @@ -8,18 +8,21 @@ static int cmd_sync(void) |
| { |
| char Buffer[MAX_PATH]; |
| DWORD dwRet; |
| - char szVolumeAccessPath[] = "\\\\.\\X:"; |
| + char szVolumeAccessPath[] = "\\\\.\\XXXX:"; |
| HANDLE hVolWrite; |
| - int success = 0; |
| + int success = 0, dos_drive_prefix; |
| |
| dwRet = GetCurrentDirectory(MAX_PATH, Buffer); |
| if ((0 == dwRet) || (dwRet > MAX_PATH)) |
| return error("Error getting current directory"); |
| |
| - if (!has_dos_drive_prefix(Buffer)) |
| + dos_drive_prefix = has_dos_drive_prefix(Buffer); |
| + if (!dos_drive_prefix) |
| return error("'%s': invalid drive letter", Buffer); |
| |
| - szVolumeAccessPath[4] = Buffer[0]; |
| + memcpy(szVolumeAccessPath, Buffer, dos_drive_prefix); |
| + szVolumeAccessPath[dos_drive_prefix] = '\0'; |
| + |
| hVolWrite = CreateFile(szVolumeAccessPath, GENERIC_READ | GENERIC_WRITE, |
| FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); |
| if (INVALID_HANDLE_VALUE == hVolWrite) |
| -- |
| 2.24.0.393.g34dc348eaf |
| |