mirror of
https://github.com/claunia/flac.git
synced 2025-12-16 18:54:26 +00:00
allow file generator to return the filesize
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user