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:
+8
-9
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user