diff options
Diffstat (limited to 'win32')
-rw-r--r-- | win32/mingw.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/win32/mingw.c b/win32/mingw.c index c420992d5..8d1da5199 100644 --- a/win32/mingw.c +++ b/win32/mingw.c | |||
@@ -1289,3 +1289,42 @@ ULONGLONG CompatGetTickCount64(void) | |||
1289 | return GetTickCount64(); | 1289 | return GetTickCount64(); |
1290 | } | 1290 | } |
1291 | #endif | 1291 | #endif |
1292 | |||
1293 | #if ENABLE_FEATURE_INSTALLER | ||
1294 | /* | ||
1295 | * Enumerate the names of all hard links to a file. The first call | ||
1296 | * provides the file name as the first argument; subsequent calls must | ||
1297 | * set the first argument to NULL. Returns 0 on error or when there are | ||
1298 | * no more links. | ||
1299 | */ | ||
1300 | int enumerate_links(const char *file, char *name) | ||
1301 | { | ||
1302 | static HANDLE h = INVALID_HANDLE_VALUE; | ||
1303 | char aname[PATH_MAX]; | ||
1304 | wchar_t wname[PATH_MAX]; | ||
1305 | DWORD length = PATH_MAX; | ||
1306 | DECLARE_PROC_ADDR(HANDLE, FindFirstFileNameW, LPCWSTR, DWORD, LPDWORD, | ||
1307 | PWSTR); | ||
1308 | DECLARE_PROC_ADDR(BOOL, FindNextFileNameW, HANDLE, LPDWORD, PWSTR); | ||
1309 | |||
1310 | if (!INIT_PROC_ADDR(kernel32.dll, FindFirstFileNameW) || | ||
1311 | !INIT_PROC_ADDR(kernel32.dll, FindNextFileNameW)) | ||
1312 | return 0; | ||
1313 | |||
1314 | if (file != NULL) { | ||
1315 | wchar_t wfile[PATH_MAX]; | ||
1316 | MultiByteToWideChar(CP_ACP, 0, file, -1, wfile, PATH_MAX); | ||
1317 | h = FindFirstFileNameW(wfile, 0, &length, wname); | ||
1318 | if (h == INVALID_HANDLE_VALUE) | ||
1319 | return 0; | ||
1320 | } | ||
1321 | else if (!FindNextFileNameW(h, &length, wname)) { | ||
1322 | FindClose(h); | ||
1323 | h = INVALID_HANDLE_VALUE; | ||
1324 | return 0; | ||
1325 | } | ||
1326 | WideCharToMultiByte(CP_ACP, 0, wname, -1, aname, PATH_MAX, NULL, NULL); | ||
1327 | realpath(aname, name); | ||
1328 | return 1; | ||
1329 | } | ||
1330 | #endif | ||