1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-07-07 21:23:12 +02:00

Update file_exists() function to work with directories on Windows.

And then let's use the similar (and faster) function on Linux too.
This commit is contained in:
Bram Matthys
2021-06-28 19:33:14 +02:00
parent 137703f04a
commit 0bd2cfd0fc
+8 -9
View File
@@ -2094,17 +2094,16 @@ int filename_has_suffix(const char *fname, const char *suffix)
return 0;
}
/** Check if the specified file exists */
/** Check if the specified file or directory exists */
int file_exists(char *file)
{
FILE *fd;
fd = fopen(file, "r");
if (!fd)
return 0;
fclose(fd);
return 1;
#ifdef _WIN32
if (_access(file, 0) == 0)
#else
if (access(file, 0) == 0)
#endif
return 1;
return 0;
}
/** Get the file creation time */