Esempio n. 1
0
static char*
fluid_file_read_full(fluid_file fp, size_t* length)
{
    size_t buflen;
    char* buffer;
    size_t n;
    /* Work out the length of the file in advance */
    if (FLUID_FSEEK(fp, 0, SEEK_END) != 0)
    {
        FLUID_LOG(FLUID_ERR, "File load: Could not seek within file");
        return NULL;
    }
    buflen = ftell(fp);
    if (FLUID_FSEEK(fp, 0, SEEK_SET) != 0)
    {
        FLUID_LOG(FLUID_ERR, "File load: Could not seek within file");
        return NULL;
    }
    FLUID_LOG(FLUID_DBG, "File load: Allocating %d bytes", buflen);
    buffer = FLUID_MALLOC(buflen);
    if (buffer == NULL) {
        FLUID_LOG(FLUID_PANIC, "Out of memory");
        return NULL;
    }
    n = FLUID_FREAD(buffer, 1, buflen, fp);
    if (n != buflen) {
        FLUID_LOG(FLUID_ERR, "Only read %d bytes; expected %d", n,
                  buflen);
        FLUID_FREE(buffer);
        return NULL;
    };
    *length = n;
    return buffer;
}
Esempio n. 2
0
/*
 * fluid_midi_file_skip
 */
int fluid_midi_file_skip(fluid_midi_file* mf, int skip)
{
	int err = FLUID_FSEEK(mf->fp, skip, SEEK_CUR);
	if (err) {
		FLUID_LOG(FLUID_ERR, "Failed to seek position in file");
		return FLUID_FAILED;
	}
	return FLUID_OK;
}
Esempio n. 3
0
size_t seek_file(void *fh, size_t pos){
//	printf("SEEK %d\n",pos);
	FLUID_FSEEK((fluid_file)fh, pos, SEEK_SET);
	return pos;
}