1
0
mirror of https://gitlab.xiph.org/xiph/ezstream.git synced 2024-11-03 04:17:18 -05:00

Expect stat() availability

This commit is contained in:
Moritz Grimm 2015-05-28 08:34:01 +02:00
parent 715be8094b
commit 6422607b1f
2 changed files with 9 additions and 27 deletions

View File

@ -353,17 +353,12 @@ metadata_t *
metadata_program(const char *program, int normalize) metadata_program(const char *program, int normalize)
{ {
metadata_t *md; metadata_t *md;
#ifdef HAVE_STAT
struct stat st; struct stat st;
#else
FILE *filep;
#endif
md = metadata_create(program); md = metadata_create(program);
md->program = 1; md->program = 1;
md->string = xstrdup(""); md->string = xstrdup("");
#ifdef HAVE_STAT
if (stat(program, &st) == -1) { if (stat(program, &st) == -1) {
log_error("%s: %s", program, strerror(errno)); log_error("%s: %s", program, strerror(errno));
metadata_free(&md); metadata_free(&md);
@ -380,14 +375,6 @@ metadata_program(const char *program, int normalize)
metadata_free(&md); metadata_free(&md);
return (NULL); return (NULL);
} }
#else
if ((filep = fopen(program, "r")) == NULL) {
log_error("%s: %s", program, strerror(errno));
metadata_free(&md);
return (NULL);
}
fclose(filep);
#endif /* HAVE_STAT */
md->normalize = normalize; md->normalize = normalize;

View File

@ -18,7 +18,15 @@
# include "config.h" # include "config.h"
#endif #endif
#include "ezstream.h" #include <sys/stat.h>
#include <errno.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include "log.h" #include "log.h"
#include "playlist.h" #include "playlist.h"
@ -255,16 +263,11 @@ struct playlist *
playlist_program(const char *filename) playlist_program(const char *filename)
{ {
struct playlist *pl; struct playlist *pl;
#ifdef HAVE_STAT
struct stat st; struct stat st;
#else
FILE *filep;
#endif
pl = _playlist_create(filename); pl = _playlist_create(filename);
pl->program = 1; pl->program = 1;
#ifdef HAVE_STAT
if (stat(filename, &st) == -1) { if (stat(filename, &st) == -1) {
log_error("%s: %s", filename, strerror(errno)); log_error("%s: %s", filename, strerror(errno));
playlist_free(&pl); playlist_free(&pl);
@ -281,14 +284,6 @@ playlist_program(const char *filename)
playlist_free(&pl); playlist_free(&pl);
return (NULL); return (NULL);
} }
#else
if ((filep = fopen(filename, "r")) == NULL) {
log_error("%s: %s", filename, strerror(errno));
playlist_free(&pl);
return (NULL);
}
fclose(filep);
#endif /* HAVE_STAT */
return (pl); return (pl);
} }