mirror of
https://gitee.com/openharmony/third_party_libsnd
synced 2025-02-17 01:20:02 +00:00
src/wav.c : Truncate the file on close for RDWR mode where the file ends up shorter than when it was opened.
This commit is contained in:
parent
e9a1817530
commit
7f6c38405a
@ -4,6 +4,10 @@
|
||||
Add test for RDWR mode where the file ends up shorter than when it was
|
||||
opened.
|
||||
|
||||
* src/wav.c
|
||||
Truncate the file on close for RDWR mode where the file ends up shorter
|
||||
than when it was opened.
|
||||
|
||||
2008-11-30 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
|
||||
* M4/add_cflags.m4
|
||||
|
14
src/wav.c
14
src/wav.c
@ -1215,6 +1215,20 @@ wav_close (SF_PRIVATE *psf)
|
||||
if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
|
||||
{ wav_write_tailer (psf) ;
|
||||
|
||||
if (psf->mode == SFM_RDWR)
|
||||
{ sf_count_t current = psf_ftell (psf) ;
|
||||
|
||||
/*
|
||||
** If the mode is RDWR and the current position is less than the
|
||||
** filelength, truncate the file.
|
||||
*/
|
||||
|
||||
if (current < psf->filelength)
|
||||
{ psf_ftruncate (psf, current) ;
|
||||
psf->filelength = current ;
|
||||
} ;
|
||||
} ;
|
||||
|
||||
psf->write_header (psf, SF_TRUE) ;
|
||||
} ;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user