mirror of
https://gitee.com/openharmony/third_party_libsnd
synced 2024-11-26 19:40:24 +00:00
sndfile-salvage: Handle files > 4 GB on Windows OS
This commit is contained in:
parent
36c5198d91
commit
6dee7120ab
@ -57,6 +57,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
`replace_read_f2i`(), thanks @bobsayshilol, (issue #702).
|
||||
* Missing samples when doing a partial read of Ogg file from index till the end
|
||||
of file, thanks @arthurt (issue #643).
|
||||
* sndfile-salvage: Handle files > 4 GB on Windows OS
|
||||
|
||||
### Security
|
||||
|
||||
|
@ -56,6 +56,12 @@
|
||||
|
||||
#define NOT(x) (! (x))
|
||||
|
||||
#ifndef _WIN32
|
||||
typedef off_t sf_off_t ;
|
||||
#else
|
||||
typedef long long sf_off_t ;
|
||||
#endif
|
||||
|
||||
|
||||
static void usage_exit (const char *progname) ;
|
||||
static void salvage_file (const char * broken_wav, const char * fixed_w64) ;
|
||||
@ -74,8 +80,8 @@ main (int argc, char *argv [])
|
||||
/*==============================================================================
|
||||
*/
|
||||
|
||||
static void lseek_or_die (int fd, off_t offset, int whence) ;
|
||||
static sf_count_t get_file_length (int fd, const char * name) ;
|
||||
static void lseek_or_die (int fd, sf_off_t offset, int whence) ;
|
||||
static sf_off_t get_file_length (int fd, const char * name) ;
|
||||
static sf_count_t find_data_offset (int fd, int format) ;
|
||||
static void copy_data (int fd, SNDFILE * sndfile, int readsize) ;
|
||||
|
||||
@ -180,9 +186,13 @@ salvage_file (const char * broken_wav, const char * fixed_w64)
|
||||
*/
|
||||
|
||||
static void
|
||||
lseek_or_die (int fd, off_t offset, int whence)
|
||||
lseek_or_die (int fd, sf_off_t offset, int whence)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
if (lseek (fd, offset, whence) < 0)
|
||||
#else
|
||||
if (_lseeki64 (fd, offset, whence) < 0)
|
||||
#endif
|
||||
{ printf ("lseek failed : %s\n", strerror (errno)) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
@ -191,9 +201,14 @@ lseek_or_die (int fd, off_t offset, int whence)
|
||||
} /* lseek_or_die */
|
||||
|
||||
|
||||
static sf_count_t
|
||||
static sf_off_t
|
||||
get_file_length (int fd, const char * name)
|
||||
{ struct stat sbuf ;
|
||||
{
|
||||
#ifndef _WIN32
|
||||
struct stat sbuf ;
|
||||
#else
|
||||
struct _stat64 sbuf ;
|
||||
#endif
|
||||
|
||||
if (sizeof (sbuf.st_size) != 8)
|
||||
{ puts ("Error : sizeof (sbuf.st_size) != 8. Was program compiled with\n"
|
||||
@ -201,7 +216,11 @@ get_file_length (int fd, const char * name)
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
#ifndef _WIN32
|
||||
if (fstat (fd, &sbuf) != 0)
|
||||
#else
|
||||
if (_fstat64 (fd, &sbuf) != 0)
|
||||
#endif
|
||||
{ printf ("Error : fstat ('%s') failed : %s\n", name, strerror (errno)) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
Loading…
Reference in New Issue
Block a user