Skip to content

Commit 85d7390

Browse files
committed
Util (Windows): use native win32 functions
1 parent 8509f97 commit 85d7390

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/util/path.c

+17
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "common/io/io.h"
44
#include "util/stringUtils.h"
55

6+
#if !_WIN32
67
const char* ffFindExecutableInPath(const char* name, FFstrbuf* result)
78
{
89
char* path = getenv("PATH");
@@ -47,6 +48,22 @@ const char* ffFindExecutableInPath(const char* name, FFstrbuf* result)
4748
ffStrbufClear(result);
4849
return "Executable not found";
4950
}
51+
#else
52+
#include <windows.h>
53+
54+
const char* ffFindExecutableInPath(const char* name, FFstrbuf* result)
55+
{
56+
char buffer[MAX_PATH + 1];
57+
DWORD length = SearchPathA(NULL, name, ".exe", sizeof(buffer), buffer, NULL);
58+
if (length == 0)
59+
{
60+
ffStrbufClear(result);
61+
return "Executable not found";
62+
}
63+
ffStrbufSetS(result, buffer);
64+
return NULL;
65+
}
66+
#endif
5067

5168
bool ffIsAbsolutePath(const char* path)
5269
{

0 commit comments

Comments
 (0)