mirror of
https://github.com/86Box/86Box.git
synced 2026-02-23 18:08:20 -07:00
Introduce plat_file_check and use it for ROM existence checking
This commit is contained in:
@@ -64,6 +64,8 @@
|
||||
# include <sys/mman.h>
|
||||
#endif
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef Q_OS_OPENBSD
|
||||
# include <pthread_np.h>
|
||||
#endif
|
||||
@@ -250,6 +252,22 @@ plat_dir_check(char *path)
|
||||
return fi.isDir() ? 1 : 0;
|
||||
}
|
||||
|
||||
int
|
||||
plat_file_check(const char *path)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
auto data = QString::fromUtf8(path).toStdWString();
|
||||
auto res = GetFileAttributesW(data.c_str());
|
||||
return (res != INVALID_FILE_ATTRIBUTES && !(res & FILE_ATTRIBUTE_DIRECTORY));
|
||||
#else
|
||||
struct stat dummy;
|
||||
if (stat(path, &dummy) < 0) {
|
||||
return 0;
|
||||
}
|
||||
return !S_ISDIR(dummy.st_mode);
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
plat_getcwd(char *bufp, int max)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user