viso: use stat to check for directory in bin_init
This commit is contained in:
@@ -25,6 +25,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
# include <string.h>
|
# include <string.h>
|
||||||
#else
|
#else
|
||||||
@@ -131,6 +132,7 @@ static track_file_t *
|
|||||||
bin_init(const char *filename, int *error)
|
bin_init(const char *filename, int *error)
|
||||||
{
|
{
|
||||||
track_file_t *tf = (track_file_t *) malloc(sizeof(track_file_t));
|
track_file_t *tf = (track_file_t *) malloc(sizeof(track_file_t));
|
||||||
|
struct stat stats;
|
||||||
|
|
||||||
if (tf == NULL) {
|
if (tf == NULL) {
|
||||||
*error = 1;
|
*error = 1;
|
||||||
@@ -142,7 +144,11 @@ bin_init(const char *filename, int *error)
|
|||||||
tf->file = plat_fopen64(tf->fn, "rb");
|
tf->file = plat_fopen64(tf->fn, "rb");
|
||||||
cdrom_image_backend_log("CDROM: binary_open(%s) = %08lx\n", tf->fn, tf->file);
|
cdrom_image_backend_log("CDROM: binary_open(%s) = %08lx\n", tf->fn, tf->file);
|
||||||
|
|
||||||
*error = (tf->file == NULL);
|
if (stat(tf->fn, &stats) != 0) {
|
||||||
|
/* Use a blank structure if stat failed. */
|
||||||
|
memset(&stats, 0, sizeof(struct stat));
|
||||||
|
}
|
||||||
|
*error = ((tf->file == NULL) || (S_ISDIR(stats.st_mode)));
|
||||||
|
|
||||||
/* Set the function pointers. */
|
/* Set the function pointers. */
|
||||||
if (!*error) {
|
if (!*error) {
|
||||||
|
Reference in New Issue
Block a user