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>
Johannes Schindelin committed
Dec 4, 2019 at 21:40 UTC
68440496c77c6d3a606537c78ea4b62eb895a64a
1 file changed
+8
-5
t/helper/test-drop-caches.c
+8
-5
@@ -6,18 +6,21 @@ static int cmd_sync(void)
6
{
7
char Buffer[MAX_PATH];
8
DWORD dwRet;
9
- char szVolumeAccessPath[] = "\\\\.\\X:";
9
+ char szVolumeAccessPath[] = "\\\\.\\XXXX:";
10
HANDLE hVolWrite;
11
- int success = 0;
11
+ int success = 0, dos_drive_prefix;
12
13
dwRet = GetCurrentDirectory(MAX_PATH, Buffer);
14
if ((0 == dwRet) || (dwRet > MAX_PATH))
15
return error("Error getting current directory");
16
17
- if ((Buffer[0] < 'A') || (Buffer[0] > 'Z'))
18
- return error("Invalid drive letter '%c'", Buffer[0]);
17
+ dos_drive_prefix = has_dos_drive_prefix(Buffer);
18
+ if (!dos_drive_prefix)
19
+ return error("'%s': invalid drive letter", Buffer);
20
+
21
+ memcpy(szVolumeAccessPath, Buffer, dos_drive_prefix);
22
+ szVolumeAccessPath[dos_drive_prefix] = '\0';
23
20
- szVolumeAccessPath[4] = Buffer[0];
24
hVolWrite = CreateFile(szVolumeAccessPath, GENERIC_READ | GENERIC_WRITE,
25
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
26
if (INVALID_HANDLE_VALUE == hVolWrite)