# HG changeset patch # User William Pitcock # Date 1214885027 18000 # Node ID aa2e0f33f55da5c18a30093575803bba874a8577 # Parent 3ba15b5aeadb94ba66c1ff4ef52fadd4a56369e6 use aud_vfs_file_get_contents(). diff -r 3ba15b5aeadb -r aa2e0f33f55d src/psf2/plugin.c --- a/src/psf2/plugin.c Mon Jun 30 22:37:17 2008 -0500 +++ b/src/psf2/plugin.c Mon Jun 30 23:03:47 2008 -0500 @@ -58,36 +58,11 @@ uint8 *filebuf; uint32 size; VFSFile *auxfile; - - auxfile = aud_vfs_fopen(filename, "rb"); - if (!auxfile) - { - char buf[PATH_MAX]; - snprintf(buf, PATH_MAX, "%s/%s", dirname(path), filename); - auxfile = aud_vfs_fopen(buf, "rb"); - - if (!auxfile) - { - printf("Unable to find auxiliary file %s\n", buf); - return AO_FAIL; - } - } + char buf[PATH_MAX]; - aud_vfs_fseek(auxfile, 0, SEEK_END); - size = aud_vfs_ftell(auxfile); - aud_vfs_fseek(auxfile, 0, SEEK_SET); - - filebuf = malloc(size); + snprintf(buf, PATH_MAX, "%s/%s", dirname(path), filename); - if (!filebuf) - { - aud_vfs_fclose(auxfile); - printf("ERROR: could not allocate %d bytes of memory\n", size); - return AO_FAIL; - } - - aud_vfs_fread(filebuf, size, 1, auxfile); - aud_vfs_fclose(auxfile); + aud_vfs_file_get_contents(buf, &filebuf, &size); *buffer = filebuf; *length = (uint64)size; @@ -97,35 +72,11 @@ void psf2_play(InputPlayback *data) { - VFSFile *file; uint8 *buffer; uint32 size, filesig; - path = strdup(data->filename); - file = aud_vfs_fopen(data->filename, "rb"); - - if (!file) - { - printf("ERROR: could not open file %s\n", data->filename); - return; - } - - aud_vfs_fseek(file, 0, SEEK_END); - size = aud_vfs_ftell(file); - aud_vfs_fseek(file, 0, SEEK_SET); - - buffer = malloc(size); - - if (!buffer) - { - aud_vfs_fclose(file); - printf("ERROR: could not allocate %d bytes of memory\n", size); - return; - } - - // read the file - aud_vfs_fread(buffer, size, 1, file); - aud_vfs_fclose(file); + path = g_strdup(data->filename); + aud_vfs_file_get_contents(data->filename, &buffer, &size); // now try to identify the file type = 0; @@ -167,6 +118,7 @@ } free(buffer); + g_free(path); } void psf2_update(unsigned char *buffer, long count, InputPlayback *playback)