Add missing glob() equivalent for Windows platforms
This commit is contained in:
@@ -48,6 +48,9 @@
|
|||||||
#else
|
#else
|
||||||
#define PRId64 "lld"
|
#define PRId64 "lld"
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_WINDOWS_H
|
||||||
|
#include <windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
@@ -961,6 +964,41 @@ _read_mode2_sectors_bincue (void *p_user_data, void *data, lsn_t lsn,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(HAVE_GLOB_H) && defined(_WIN32)
|
||||||
|
static inline void Win32Glob(const char* pattern, const char* szCurPath, char ***drives, unsigned int *num_files)
|
||||||
|
{
|
||||||
|
char szPath[MAX_PATH];
|
||||||
|
WIN32_FIND_DATAA ffd;
|
||||||
|
HANDLE hFind;
|
||||||
|
BOOL bFound;
|
||||||
|
|
||||||
|
SetCurrentDirectoryA(szCurPath);
|
||||||
|
|
||||||
|
hFind = FindFirstFileA(pattern, &ffd);
|
||||||
|
bFound = (hFind != INVALID_HANDLE_VALUE);
|
||||||
|
while (bFound) {
|
||||||
|
cdio_add_device_list(drives, ffd.cFileName, num_files);
|
||||||
|
bFound = FindNextFileA(hFind, &ffd);
|
||||||
|
}
|
||||||
|
if (hFind != INVALID_HANDLE_VALUE)
|
||||||
|
FindClose(hFind);
|
||||||
|
|
||||||
|
hFind = FindFirstFileA("*", &ffd);
|
||||||
|
bFound = (hFind != INVALID_HANDLE_VALUE);
|
||||||
|
while (bFound) {
|
||||||
|
if ( (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) &&
|
||||||
|
(strcmp(ffd.cFileName, ".") != 0) && (strcmp(ffd.cFileName, "..") != 0) ) {
|
||||||
|
GetFullPathNameA(ffd.cFileName, sizeof(szPath), szPath, NULL);
|
||||||
|
Win32Glob(pattern, szPath, drives, num_files);
|
||||||
|
SetCurrentDirectoryA(szCurPath);
|
||||||
|
}
|
||||||
|
bFound = FindNextFileA(hFind, &ffd);
|
||||||
|
}
|
||||||
|
if (hFind != INVALID_HANDLE_VALUE)
|
||||||
|
FindClose(hFind);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Return an array of strings giving possible BIN/CUE disk images.
|
Return an array of strings giving possible BIN/CUE disk images.
|
||||||
*/
|
*/
|
||||||
@@ -978,6 +1016,10 @@ cdio_get_devices_bincue (void)
|
|||||||
cdio_add_device_list(&drives, globbuf.gl_pathv[i], &num_files);
|
cdio_add_device_list(&drives, globbuf.gl_pathv[i], &num_files);
|
||||||
}
|
}
|
||||||
globfree(&globbuf);
|
globfree(&globbuf);
|
||||||
|
#elif defined(_WIN32)
|
||||||
|
char szStartDir[MAX_PATH];
|
||||||
|
GetCurrentDirectoryA(sizeof(szStartDir), szStartDir);
|
||||||
|
Win32Glob("*.cue", szStartDir, &drives, &num_files);
|
||||||
#else
|
#else
|
||||||
cdio_add_device_list(&drives, DEFAULT_CDIO_DEVICE, &num_files);
|
cdio_add_device_list(&drives, DEFAULT_CDIO_DEVICE, &num_files);
|
||||||
#endif /*HAVE_GLOB_H*/
|
#endif /*HAVE_GLOB_H*/
|
||||||
|
|||||||
@@ -34,6 +34,9 @@
|
|||||||
#ifdef HAVE_GLOB_H
|
#ifdef HAVE_GLOB_H
|
||||||
#include <glob.h>
|
#include <glob.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_WINDOWS_H
|
||||||
|
#include <windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <cdio/bytesex.h>
|
#include <cdio/bytesex.h>
|
||||||
#include <cdio/ds.h>
|
#include <cdio/ds.h>
|
||||||
@@ -1122,6 +1125,41 @@ _eject_media_nrg(void *obj)
|
|||||||
return DRIVER_OP_UNSUPPORTED;
|
return DRIVER_OP_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(HAVE_GLOB_H) && defined(_WIN32)
|
||||||
|
static inline void Win32Glob(const char* pattern, const char* szCurPath, char ***drives, unsigned int *num_files)
|
||||||
|
{
|
||||||
|
char szPath[MAX_PATH];
|
||||||
|
WIN32_FIND_DATAA ffd;
|
||||||
|
HANDLE hFind;
|
||||||
|
BOOL bFound;
|
||||||
|
|
||||||
|
SetCurrentDirectoryA(szCurPath);
|
||||||
|
|
||||||
|
hFind = FindFirstFileA(pattern, &ffd);
|
||||||
|
bFound = (hFind != INVALID_HANDLE_VALUE);
|
||||||
|
while (bFound) {
|
||||||
|
cdio_add_device_list(drives, ffd.cFileName, num_files);
|
||||||
|
bFound = FindNextFileA(hFind, &ffd);
|
||||||
|
}
|
||||||
|
if (hFind != INVALID_HANDLE_VALUE)
|
||||||
|
FindClose(hFind);
|
||||||
|
|
||||||
|
hFind = FindFirstFileA("*", &ffd);
|
||||||
|
bFound = (hFind != INVALID_HANDLE_VALUE);
|
||||||
|
while (bFound) {
|
||||||
|
if ( (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) &&
|
||||||
|
(strcmp(ffd.cFileName, ".") != 0) && (strcmp(ffd.cFileName, "..") != 0) ) {
|
||||||
|
GetFullPathNameA(ffd.cFileName, sizeof(szPath), szPath, NULL);
|
||||||
|
Win32Glob(pattern, szPath, drives, num_files);
|
||||||
|
SetCurrentDirectoryA(szCurPath);
|
||||||
|
}
|
||||||
|
bFound = FindNextFileA(hFind, &ffd);
|
||||||
|
}
|
||||||
|
if (hFind != INVALID_HANDLE_VALUE)
|
||||||
|
FindClose(hFind);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Return an array of strings giving possible NRG disk images.
|
Return an array of strings giving possible NRG disk images.
|
||||||
*/
|
*/
|
||||||
@@ -1139,6 +1177,10 @@ cdio_get_devices_nrg (void)
|
|||||||
cdio_add_device_list(&drives, globbuf.gl_pathv[i], &num_files);
|
cdio_add_device_list(&drives, globbuf.gl_pathv[i], &num_files);
|
||||||
}
|
}
|
||||||
globfree(&globbuf);
|
globfree(&globbuf);
|
||||||
|
#elif defined(_WIN32)
|
||||||
|
char szStartDir[MAX_PATH];
|
||||||
|
GetCurrentDirectoryA(sizeof(szStartDir), szStartDir);
|
||||||
|
Win32Glob("*.nrg", szStartDir, &drives, &num_files);
|
||||||
#else
|
#else
|
||||||
cdio_add_device_list(&drives, DEFAULT_CDIO_DEVICE, &num_files);
|
cdio_add_device_list(&drives, DEFAULT_CDIO_DEVICE, &num_files);
|
||||||
#endif /*HAVE_GLOB_H*/
|
#endif /*HAVE_GLOB_H*/
|
||||||
|
|||||||
Reference in New Issue
Block a user