From 0ee0c7bdf6600b2b0e41a1ec173e943ba4c41320 Mon Sep 17 00:00:00 2001 From: udf Date: Sun, 25 Feb 2024 00:48:51 +0200 Subject: [PATCH] Replace FileSystemEntryExists with PathFileExistsW --- .../coreaudioconnect/connector/Makefile | 2 +- .../connector/dllinterface.cpp | 28 +++++++------------ 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/components/encoder/coreaudioconnect/connector/Makefile b/components/encoder/coreaudioconnect/connector/Makefile index 63cb6aad..807b9b86 100644 --- a/components/encoder/coreaudioconnect/connector/Makefile +++ b/components/encoder/coreaudioconnect/connector/Makefile @@ -17,7 +17,7 @@ OBJECTS = dllinterface.o main.o BINARY = $(BOCA_PATH)/$(BINDIR)/boca_$(TYPE)_$(TARGET)$(X64).$(VERSION)$(EXECUTABLE) DEFINE = -DUNICODE -LIBS = -lole32 -lshell32 +LIBS = -lole32 -lshell32 -lshlwapi CCOPTS = -Wno-multichar -I"$(SRCDIR)"/$(BOCA_PATH)/include -I"$(SRCDIR)"/$(BOCA_PATH)/include/support/apple $(DEFINE) LDOPTS = -L $(BOCA_PATH)/$(LIBDIR) $(LIBS) diff --git a/components/encoder/coreaudioconnect/connector/dllinterface.cpp b/components/encoder/coreaudioconnect/connector/dllinterface.cpp index c5b89ddd..2d2cadac 100644 --- a/components/encoder/coreaudioconnect/connector/dllinterface.cpp +++ b/components/encoder/coreaudioconnect/connector/dllinterface.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #ifdef __WINE__ # include @@ -45,6 +46,7 @@ # define SetDllDirectoryW SetDllDirectoryA # define LoadLibraryW LoadLibraryA +# define PathFileExistsW PathFileExistsA # define FindFirstFileW FindFirstFileA # define FindNextFileW FindNextFileA # define DeleteFileW DeleteFileA @@ -82,16 +84,6 @@ HINSTANCE coreaudiodll = NULL; #define PATH_LENGTH 2048 -static bool FileSystemEntryExists(const wchar_t *path) -{ - WIN32_FIND_DATAW findData; - HANDLE handle = FindFirstFileW(path, &findData); - - FindClose(handle); - - return (handle != INVALID_HANDLE_VALUE); -} - static const wchar_t *GetSystemDirectory(int id) { static wchar_t commonFilesDir[PATH_LENGTH] = { 0 }; @@ -152,7 +144,7 @@ static const wchar_t *GetCacheFolder(const char *applicationPrefix) fclose(_wfopen(cacheFolder, wstring("w"))); - if (FileSystemEntryExists(cacheFolder)) + if (PathFileExistsW(cacheFolder)) { DeleteFileW(cacheFolder); @@ -222,7 +214,7 @@ static void FindDependenciesFolders(const wchar_t *packageFolder, wchar_t **pack wcscpy(manifestPath, packageFolder); wcscat(manifestPath, wstring("AppxManifest.xml")); - if (!FileSystemEntryExists(manifestPath)) return; + if (!PathFileExistsW(manifestPath)) return; /* Load app manifest. */ @@ -351,15 +343,15 @@ static void CopyLibrary(const wchar_t *libName, wchar_t **packageFolders, const wcscpy(libFile, packageFolders[i]); wcscat(libFile, libName); - if (!FileSystemEntryExists(libFile)) continue; + if (!PathFileExistsW(libFile)) continue; wcscpy(sourceFile, libFile); } /* Check file existence and skip already existing files. */ - if (!FileSystemEntryExists(sourceFile) || - FileSystemEntryExists(targetFile)) return; + if (!PathFileExistsW(sourceFile) || + PathFileExistsW(targetFile)) return; /* Prepare input and output files. */ @@ -443,7 +435,7 @@ static void CacheCoreAudioLibraries(const wchar_t *cacheFolder) wcscpy(packageIdFile, cacheFolder); wcscat(packageIdFile, wstring("PackageId")); - if (FileSystemEntryExists(packageIdFile)) + if (PathFileExistsW(packageIdFile)) { FILE *in = _wfopen(packageIdFile, wstring("r")); char line[256] = { 0 }; @@ -497,13 +489,13 @@ bool LoadCoreAudioDLL(const char *applicationPrefix) wcscpy(coreAudioDir, GetSystemDirectory(CSIDL_PROGRAM_FILES_COMMON)); wcscat(coreAudioDir, wstring("Apple\\Apple Application Support\\")); - if (!FileSystemEntryExists(coreAudioDir)) + if (!PathFileExistsW(coreAudioDir)) { wcscpy(coreAudioDir, GetSystemDirectory(CSIDL_PROGRAM_FILES)); wcscat(coreAudioDir, wstring("iTunes\\")); } - if (!FileSystemEntryExists(coreAudioDir)) + if (!PathFileExistsW(coreAudioDir)) { wcscpy(coreAudioDir, GetCacheFolder(applicationPrefix)); wcscat(coreAudioDir, wstring("boca.encoder.coreaudio\\"));