Skip to content

Commit 6844049

Browse files
committed
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 <[email protected]>
1 parent 9ac92fe commit 6844049

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

t/helper/test-drop-caches.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,21 @@ static int cmd_sync(void)
66
{
77
char Buffer[MAX_PATH];
88
DWORD dwRet;
9-
char szVolumeAccessPath[] = "\\\\.\\X:";
9+
char szVolumeAccessPath[] = "\\\\.\\XXXX:";
1010
HANDLE hVolWrite;
11-
int success = 0;
11+
int success = 0, dos_drive_prefix;
1212

1313
dwRet = GetCurrentDirectory(MAX_PATH, Buffer);
1414
if ((0 == dwRet) || (dwRet > MAX_PATH))
1515
return error("Error getting current directory");
1616

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';
1923

20-
szVolumeAccessPath[4] = Buffer[0];
2124
hVolWrite = CreateFile(szVolumeAccessPath, GENERIC_READ | GENERIC_WRITE,
2225
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
2326
if (INVALID_HANDLE_VALUE == hVolWrite)

0 commit comments

Comments
 (0)