Now checking if a rom is a regular file before opening.
Patch 2214354 by riccardom.
This commit is contained in:
parent
3fd38256e5
commit
a509bcb896
|
@ -19,11 +19,19 @@
|
||||||
|
|
||||||
#include "ROMReader.h"
|
#include "ROMReader.h"
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#ifdef HAVE_LIBZZIP
|
#ifdef HAVE_LIBZZIP
|
||||||
#include <zzip/zzip.h>
|
#include <zzip/zzip.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
#define stat(...) _stat(__VA_ARGS__)
|
||||||
|
#define S_IFMT _S_IFMT
|
||||||
|
#define S_IFREG _S_IFREG
|
||||||
|
#endif
|
||||||
|
|
||||||
ROMReader_struct * ROMReaderInit(char ** filename)
|
ROMReader_struct * ROMReaderInit(char ** filename)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_LIBZ
|
#ifdef HAVE_LIBZ
|
||||||
|
@ -62,6 +70,14 @@ ROMReader_struct STDROMReader =
|
||||||
|
|
||||||
void * STDROMReaderInit(const char * filename)
|
void * STDROMReaderInit(const char * filename)
|
||||||
{
|
{
|
||||||
|
struct stat sb;
|
||||||
|
|
||||||
|
if (stat(filename, &sb) == -1)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if ((sb.st_mode & S_IFMT) != S_IFREG)
|
||||||
|
return 0;
|
||||||
|
|
||||||
return (void *) fopen(filename, "rb");
|
return (void *) fopen(filename, "rb");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue