summaryrefslogtreecommitdiff
path: root/playlist.c
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2011-05-22 10:49:43 +0200
committerGravatar waker <wakeroid@gmail.com>2011-05-22 10:49:43 +0200
commitea2d9e2df3d3d90d7dbcb7ac644a73ae767f7c9e (patch)
tree9f692d5a9689210acf792129d283fa156f2ce0f1 /playlist.c
parent34433a67885bdb99858e80bd270516c1b6f3cb55 (diff)
changed cue loader to use VFS, for reading from archives
Diffstat (limited to 'playlist.c')
-rw-r--r--playlist.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/playlist.c b/playlist.c
index 61d77997..28f8f730 100644
--- a/playlist.c
+++ b/playlist.c
@@ -1130,31 +1130,33 @@ plt_insert_cue (playlist_t *plt, playItem_t *after, playItem_t *origin, int nums
char cuename[len+5];
strcpy (cuename, fname);
strcpy (cuename+len, ".cue");
- FILE *fp = fopen (cuename, "rb");
+ DB_FILE *fp = vfs_fopen (cuename);
if (!fp) {
char *ptr = cuename + len-1;
while (ptr >= cuename && *ptr != '.') {
ptr--;
}
strcpy (ptr+1, "cue");
- fp = fopen (cuename, "rb");
+ fp = vfs_fopen (cuename);
if (!fp) {
return NULL;
}
}
- fseek (fp, 0, SEEK_END);
- size_t sz = ftell (fp);
+ size_t sz = vfs_fgetlength (fp);
if (sz == 0) {
- fclose (fp);
+ vfs_fclose (fp);
return NULL;
}
- rewind (fp);
- uint8_t buf[sz];
- if (fread (buf, 1, sz, fp) != sz) {
- fclose (fp);
+ uint8_t *buf = alloca(sz);
+ if (!buf) {
+ vfs_fclose (fp);
return NULL;
}
- fclose (fp);
+ if (vfs_fread (buf, 1, sz, fp) != sz) {
+ vfs_fclose (fp);
+ return NULL;
+ }
+ vfs_fclose (fp);
return plt_insert_cue_from_buffer (plt, after, origin, buf, sz, numsamples, samplerate);
}