mirror of
https://github.com/claunia/flac.git
synced 2025-12-16 18:54:26 +00:00
complete largefile support
This commit is contained in:
@@ -16,6 +16,10 @@
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "FLAC/assert.h"
|
||||
#include "private/bitbuffer.h" /* from the libFLAC private include area */
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -16,6 +16,19 @@
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#if defined _MSC_VER || defined __MINGW32__
|
||||
//@@@ [2G limit] hacks for MSVC6
|
||||
#define fseeko fseek
|
||||
#define ftello ftell
|
||||
#endif
|
||||
#include "decoders.h"
|
||||
#include "file_utils.h"
|
||||
#include "metadata_utils.h"
|
||||
@@ -24,10 +37,6 @@
|
||||
#include "FLAC/seekable_stream_decoder.h"
|
||||
#include "FLAC/stream_decoder.h"
|
||||
#include "share/grabbag.h"
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
typedef struct {
|
||||
FILE *file;
|
||||
@@ -43,7 +52,7 @@ static FLAC__StreamMetadata streaminfo_, padding_, seektable_, application1_, ap
|
||||
static FLAC__StreamMetadata *expected_metadata_sequence_[8];
|
||||
static unsigned num_expected_;
|
||||
static const char *flacfilename_ = "metadata.flac";
|
||||
static unsigned flacfilesize_;
|
||||
static off_t flacfilesize_;
|
||||
|
||||
static FLAC__bool die_(const char *msg)
|
||||
{
|
||||
@@ -265,7 +274,7 @@ static FLAC__bool stream_decoder_test_respond_(FLAC__StreamDecoder *decoder, str
|
||||
|
||||
dcd->current_metadata_number = 0;
|
||||
|
||||
if(fseek(dcd->file, 0, SEEK_SET) < 0) {
|
||||
if(fseeko(dcd->file, 0, SEEK_SET) < 0) {
|
||||
printf("FAILED rewinding input, errno = %d\n", errno);
|
||||
return false;
|
||||
}
|
||||
@@ -371,7 +380,7 @@ static FLAC__bool test_stream_decoder()
|
||||
printf("opening FLAC file... ");
|
||||
decoder_client_data.file = fopen(flacfilename_, "rb");
|
||||
if(0 == decoder_client_data.file) {
|
||||
printf("ERROR\n");
|
||||
printf("ERROR (%s)\n", strerror(errno));
|
||||
return false;
|
||||
}
|
||||
printf("OK\n");
|
||||
@@ -462,7 +471,7 @@ static FLAC__bool test_stream_decoder()
|
||||
decoder_client_data.current_metadata_number = 0;
|
||||
|
||||
printf("rewinding input... ");
|
||||
if(fseek(decoder_client_data.file, 0, SEEK_SET) < 0) {
|
||||
if(fseeko(decoder_client_data.file, 0, SEEK_SET) < 0) {
|
||||
printf("FAILED, errno = %d\n", errno);
|
||||
return false;
|
||||
}
|
||||
@@ -814,7 +823,7 @@ static FLAC__SeekableStreamDecoderSeekStatus seekable_stream_decoder_seek_callba
|
||||
if(dcd->error_occurred)
|
||||
return FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_ERROR;
|
||||
|
||||
if(fseek(dcd->file, (long)absolute_byte_offset, SEEK_SET) < 0) {
|
||||
if(fseeko(dcd->file, (off_t)absolute_byte_offset, SEEK_SET) < 0) {
|
||||
dcd->error_occurred = true;
|
||||
return FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_ERROR;
|
||||
}
|
||||
@@ -825,7 +834,7 @@ static FLAC__SeekableStreamDecoderSeekStatus seekable_stream_decoder_seek_callba
|
||||
static FLAC__SeekableStreamDecoderTellStatus seekable_stream_decoder_tell_callback_(const FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data)
|
||||
{
|
||||
seekable_stream_decoder_client_data_struct *dcd = (seekable_stream_decoder_client_data_struct*)client_data;
|
||||
long offset;
|
||||
off_t offset;
|
||||
|
||||
(void)decoder;
|
||||
|
||||
@@ -837,7 +846,7 @@ static FLAC__SeekableStreamDecoderTellStatus seekable_stream_decoder_tell_callba
|
||||
if(dcd->error_occurred)
|
||||
return FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_ERROR;
|
||||
|
||||
offset = ftell(dcd->file);
|
||||
offset = ftello(dcd->file);
|
||||
*absolute_byte_offset = (FLAC__uint64)offset;
|
||||
|
||||
if(offset < 0) {
|
||||
@@ -940,7 +949,7 @@ static FLAC__bool seekable_stream_decoder_test_respond_(FLAC__SeekableStreamDeco
|
||||
|
||||
dcd->current_metadata_number = 0;
|
||||
|
||||
if(fseek(dcd->file, 0, SEEK_SET) < 0) {
|
||||
if(fseeko(dcd->file, 0, SEEK_SET) < 0) {
|
||||
printf("FAILED rewinding input, errno = %d\n", errno);
|
||||
return false;
|
||||
}
|
||||
@@ -1076,7 +1085,7 @@ static FLAC__bool test_seekable_stream_decoder()
|
||||
printf("opening FLAC file... ");
|
||||
decoder_client_data.file = fopen(flacfilename_, "rb");
|
||||
if(0 == decoder_client_data.file) {
|
||||
printf("ERROR\n");
|
||||
printf("ERROR (%s)\n", strerror(errno));
|
||||
return false;
|
||||
}
|
||||
printf("OK\n");
|
||||
@@ -1176,7 +1185,7 @@ static FLAC__bool test_seekable_stream_decoder()
|
||||
decoder_client_data.current_metadata_number = 0;
|
||||
|
||||
printf("rewinding input... ");
|
||||
if(fseek(decoder_client_data.file, 0, SEEK_SET) < 0) {
|
||||
if(fseeko(decoder_client_data.file, 0, SEEK_SET) < 0) {
|
||||
printf("FAILED, errno = %d\n", errno);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,10 @@
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "encoders.h"
|
||||
#include "file_utils.h"
|
||||
#include "metadata_utils.h"
|
||||
|
||||
@@ -16,6 +16,10 @@
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "file_utils.h"
|
||||
#include "FLAC/assert.h"
|
||||
#include "FLAC/stream_encoder.h"
|
||||
@@ -61,7 +65,7 @@ static void encoder_metadata_callback_(const FLAC__StreamEncoder *encoder, const
|
||||
(void)encoder, (void)metadata, (void)client_data;
|
||||
}
|
||||
|
||||
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__bool file_utils__generate_flacfile(const char *output_filename, off_t *output_filesize, unsigned length, const FLAC__StreamMetadata *streaminfo, FLAC__StreamMetadata **metadata, unsigned num_metadata)
|
||||
{
|
||||
FLAC__int32 samples[1024];
|
||||
FLAC__StreamEncoder *encoder;
|
||||
@@ -136,7 +140,7 @@ FLAC__bool file_utils__generate_flacfile(const char *output_filename, unsigned *
|
||||
if(stat(output_filename, &filestats) != 0)
|
||||
return false;
|
||||
else
|
||||
*output_filesize = (unsigned)filestats.st_size;
|
||||
*output_filesize = filestats.st_size;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -19,8 +19,17 @@
|
||||
#ifndef FLAC__TEST_LIBFLAC_FILE_UTILS_H
|
||||
#define FLAC__TEST_LIBFLAC_FILE_UTILS_H
|
||||
|
||||
#include "FLAC/format.h"
|
||||
/* needed because of off_t */
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
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);
|
||||
#include "FLAC/format.h"
|
||||
#include <stdlib.h> /* for off_t */
|
||||
#if defined _MSC_VER || defined __MINGW32__
|
||||
#include <sys/types.h> /* for off_t */
|
||||
#endif
|
||||
|
||||
FLAC__bool file_utils__generate_flacfile(const char *output_filename, off_t *output_filesize, unsigned length, const FLAC__StreamMetadata *streaminfo, FLAC__StreamMetadata **metadata, unsigned num_metadata);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -16,6 +16,10 @@
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "FLAC/assert.h"
|
||||
#include "FLAC/format.h"
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -16,6 +16,10 @@
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "bitbuffer.h"
|
||||
#include "decoders.h"
|
||||
#include "encoders.h"
|
||||
|
||||
@@ -16,6 +16,10 @@
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "metadata.h"
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
@@ -16,24 +16,30 @@
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "file_utils.h"
|
||||
#include "metadata_utils.h"
|
||||
#include "FLAC/assert.h"
|
||||
#include "FLAC/file_decoder.h"
|
||||
#include "FLAC/metadata.h"
|
||||
#include "share/grabbag.h"
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h> /* for malloc() */
|
||||
|
||||
#if defined _MSC_VER || defined __MINGW32__
|
||||
#include <sys/utime.h> /* for utime() */
|
||||
#include <io.h> /* for chmod() */
|
||||
//@@@ [2G limit] hacks for MSVC6
|
||||
#define fseeko fseek
|
||||
#define ftello ftell
|
||||
#else
|
||||
#include <sys/types.h> /* some flavors of BSD (like OS X) require this to get time_t */
|
||||
#include <utime.h> /* for utime() */
|
||||
#include <unistd.h> /* for chown(), unlink() */
|
||||
#endif
|
||||
#include <sys/stat.h> /* for stat(), maybe chmod() */
|
||||
#include "file_utils.h"
|
||||
#include "metadata_utils.h"
|
||||
#include "FLAC/assert.h"
|
||||
#include "FLAC/file_decoder.h"
|
||||
#include "FLAC/metadata.h"
|
||||
#include "share/grabbag.h"
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
@@ -258,14 +264,14 @@ static size_t chain_write_cb_(const void *ptr, size_t size, size_t nmemb, FLAC__
|
||||
|
||||
static int chain_seek_cb_(FLAC__IOHandle handle, FLAC__int64 offset, int whence)
|
||||
{
|
||||
long o = (long)offset;
|
||||
off_t o = (off_t)offset;
|
||||
FLAC__ASSERT(offset == o);
|
||||
return fseek((FILE*)handle, o, whence);
|
||||
return fseeko((FILE*)handle, o, whence);
|
||||
}
|
||||
|
||||
static FLAC__int64 chain_tell_cb_(FLAC__IOHandle handle)
|
||||
{
|
||||
return ftell((FILE*)handle);
|
||||
return ftello((FILE*)handle);
|
||||
}
|
||||
|
||||
static int chain_eof_cb_(FLAC__IOHandle handle)
|
||||
|
||||
@@ -16,6 +16,10 @@
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "FLAC/assert.h"
|
||||
#include "FLAC/metadata.h"
|
||||
#include "metadata_utils.h"
|
||||
|
||||
@@ -20,6 +20,10 @@
|
||||
* These are not tests, just utility functions used by the metadata tests
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "metadata_utils.h"
|
||||
#include "FLAC/metadata.h"
|
||||
#include <stdio.h>
|
||||
|
||||
Reference in New Issue
Block a user