Commit 83761b9f authored by Josh Coalson's avatar Josh Coalson
Browse files

allow file generator to return the filesize

parent d19afe48
......@@ -92,7 +92,7 @@ FLAC__bool file_utils__remove_file(const char *filename)
return file_utils__change_stats(filename, /*read_only=*/false) && 0 == unlink(filename);
}
FLAC__bool file_utils__generate_flacfile(const char *output_filename, unsigned length, const FLAC__StreamMetaData *streaminfo, FLAC__StreamMetaData **metadata, unsigned num_metadata)
FLAC__bool file_utils__generate_flacfile(const char *output_filename, unsigned *output_filesize, unsigned length, const FLAC__StreamMetaData *streaminfo, FLAC__StreamMetaData **metadata, unsigned num_metadata)
{
FLAC__int32 samples[1024];
FLAC__StreamEncoder *encoder;
......@@ -160,5 +160,14 @@ FLAC__bool file_utils__generate_flacfile(const char *output_filename, unsigned l
FLAC__stream_encoder_delete(encoder);
if(0 != output_filesize) {
struct stat filestats;
if(stat(output_filename, &filestats) != 0)
return false;
else
*output_filesize = (unsigned)filestats.st_size;
}
return true;
}
......@@ -22,4 +22,4 @@ FLAC__bool file_utils__change_stats(const char *filename, FLAC__bool read_only);
FLAC__bool file_utils__remove_file(const char *filename);
FLAC__bool file_utils__generate_flacfile(const char *output_filename, unsigned length, const FLAC__StreamMetaData *streaminfo, FLAC__StreamMetaData **metadata, unsigned num_metadata);
FLAC__bool file_utils__generate_flacfile(const char *output_filename, unsigned *output_filesize, unsigned length, const FLAC__StreamMetaData *streaminfo, FLAC__StreamMetaData **metadata, unsigned num_metadata);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment