struct stat buf;
const char *base_name;
int n;
+ int fd;
if (file_name == NULL)
return NULL;
if (n == 1)
return mime_types[0];
+ file = fopen (file_name, "r");
+ if (file == NULL)
+ {
+ free (data);
+ return XDG_MIME_TYPE_UNKNOWN;
+ }
+
if (!statbuf)
{
- if (stat (file_name, &buf) != 0)
+ fd = fileno(file);
+ if (fstat (fd, &buf) != 0)
return XDG_MIME_TYPE_UNKNOWN;
statbuf = &buf;
if (data == NULL)
return XDG_MIME_TYPE_UNKNOWN;
- file = fopen (file_name, "r");
- if (file == NULL)
- {
- free (data);
- return XDG_MIME_TYPE_UNKNOWN;
- }
-
bytes_read = fread (data, 1, max_extent, file);
if (ferror (file))
{