Now checking if a rom is a regular file before opening.

Patch 2214354 by riccardom.
This commit is contained in:
yabause 2008-11-02 21:52:15 +00:00
parent 3fd38256e5
commit a509bcb896
1 changed files with 16 additions and 0 deletions

View File

@ -19,11 +19,19 @@
#include "ROMReader.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#ifdef HAVE_LIBZZIP
#include <zzip/zzip.h>
#endif
#ifdef WIN32
#define stat(...) _stat(__VA_ARGS__)
#define S_IFMT _S_IFMT
#define S_IFREG _S_IFREG
#endif
ROMReader_struct * ROMReaderInit(char ** filename)
{
#ifdef HAVE_LIBZ
@ -62,6 +70,14 @@ ROMReader_struct STDROMReader =
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");
}