[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug ld/25713] Linker(ld.exe) runs in Windows unable to find file if pat
From: |
fredrick.eisele at gmail dot com |
Subject: |
[Bug ld/25713] Linker(ld.exe) runs in Windows unable to find file if path length is more than 260 characters. |
Date: |
Wed, 16 Feb 2022 18:41:06 +0000 |
https://sourceware.org/bugzilla/show_bug.cgi?id=25713
--- Comment #24 from Fred Eisele <fredrick.eisele at gmail dot com> ---
Here is a sample program that I think demonstrates the relevant functions.
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <conio.h>
#include <stdlib.h>
#include <windows.h>
/**
*
https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getfullpathnamew
*
https://docs.microsoft.com/en-us/windows/win32/api/stringapiset/nf-stringapiset-multibytetowidechar
* @return
*/
int main() {
wchar_t **lpFilePart = {NULL};
const char prefix[] = "\\\\?\\";
const char *paths[] = {
"C:\\tools\\foo.o",
"C:\\tools\\.\\foo.o",
"C:\\tools\\msys64\\..\\foo.o",
".\\foo.o",
".\\increasepath\\increasepath\\increasepath\\increasepath\\"
"increasepath\\increasepath\\increasepath\\increasepath\\increasepath\\"
"increasepath\\increasepath\\increasepath\\increasepath\\increasepath\\"
"increasepath\\increasepath\\increasepath\\increasepath\\increasepath\\"
"increasepath\\increasepath\\test.o",
".\\increasepath\\increasepath\\.\\.\\increasepath\\increasepath\\"
"increasepath\\increasepath\\..\\..\\increasepath\\increasepath\\increasepath\\increasepath\\increasepath\\"
"increasepath\\increasepath\\increasepath\\increasepath\\increasepath\\"
"increasepath\\increasepath\\increasepath\\increasepath\\increasepath\\"
"increasepath\\increasepath\\test.o"
};
setbuf(stderr, NULL);
int loopLimit = sizeof(paths)/sizeof(*paths);
for (int ix = 0; ix < loopLimit; ix++) {
const char *partPathOrig = paths[ix];
/*
* Converting from the partial path from ascii to unicode.
* Calling with lpWideCharStr set to null returns the length.
* Calling with cbMultiByte set to -1 includes the terminating null.
*/
int partPathWSize = MultiByteToWideChar(CP_UTF8, 0, partPathOrig, -1, NULL,
0);
wchar_t *partPath = calloc(partPathWSize, sizeof(wchar_t));
MultiByteToWideChar(CP_UTF8, 0, partPathOrig, -1, partPath, partPathWSize);
fprintf(stderr, "PartPath: size = %d val = %ls\n", partPathWSize,
partPath);
/*
* Getting the full path from the provided partial path.
*
*/
long fullPathWSize = GetFullPathNameW(partPath, 0, NULL, lpFilePart);
wchar_t *fullPath = calloc(fullPathWSize, sizeof(wchar_t));
long copiedPathLen = GetFullPathNameW(partPath, fullPathWSize, fullPath,
lpFilePart);
fprintf(stderr, "PathLen = %d LastError = %d\n", copiedPathLen,
GetLastError());
fprintf(stderr, "FullPath: size = %d val: %ls\n", fullPathWSize, fullPath);
free(fullPath);
free(partPath);
}
return 0;
}
--
You are receiving this mail because:
You are on the CC list for the bug.
- [Bug ld/25713] Linker(ld.exe) runs in Windows unable to find file if path length is more than 260 characters., fredrick.eisele at gmail dot com, 2022/02/15
- [Bug ld/25713] Linker(ld.exe) runs in Windows unable to find file if path length is more than 260 characters., nickc at redhat dot com, 2022/02/16
- [Bug ld/25713] Linker(ld.exe) runs in Windows unable to find file if path length is more than 260 characters.,
fredrick.eisele at gmail dot com <=
- [Bug ld/25713] Linker(ld.exe) runs in Windows unable to find file if path length is more than 260 characters., fredrick.eisele at gmail dot com, 2022/02/16
- [Bug ld/25713] Linker(ld.exe) runs in Windows unable to find file if path length is more than 260 characters., fredrick.eisele at gmail dot com, 2022/02/16
- [Bug ld/25713] Linker(ld.exe) runs in Windows unable to find file if path length is more than 260 characters., torbjorn.svensson at st dot com, 2022/02/17
- [Bug ld/25713] Linker(ld.exe) runs in Windows unable to find file if path length is more than 260 characters., fredrick.eisele at gmail dot com, 2022/02/17
- [Bug ld/25713] Linker(ld.exe) runs in Windows unable to find file if path length is more than 260 characters., torbjorn.svensson at st dot com, 2022/02/17
- [Bug ld/25713] Linker(ld.exe) runs in Windows unable to find file if path length is more than 260 characters., fredrick.eisele at gmail dot com, 2022/02/17
- [Bug ld/25713] Linker(ld.exe) runs in Windows unable to find file if path length is more than 260 characters., torbjorn.svensson at st dot com, 2022/02/17
- [Bug ld/25713] Linker(ld.exe) runs in Windows unable to find file if path length is more than 260 characters., fredrick.eisele at gmail dot com, 2022/02/17
- [Bug ld/25713] Linker(ld.exe) runs in Windows unable to find file if path length is more than 260 characters., fredrick.eisele at gmail dot com, 2022/02/17
- [Bug ld/25713] Linker(ld.exe) runs in Windows unable to find file if path length is more than 260 characters., fredrick.eisele at gmail dot com, 2022/02/17