work related to moving some file utils into the new file_utils convenience lib

This commit is contained in:
Josh Coalson
2002-10-30 06:18:13 +00:00
parent cf6e2ca7b8
commit 5843fc21fa
24 changed files with 32 additions and 212 deletions

View File

@@ -23,7 +23,7 @@ topdir = ../..
PROGRAM_NAME = test_libFLAC++
INCLUDES = -I$(topdir)/include
LIBS = -lFLAC++ -lFLAC -lm
LIBS = -lFLAC++ -lFLAC -lfile_utils -lm
OBJS = \
decoders.o \
encoders.o \

View File

@@ -52,7 +52,7 @@ CPP_OBJS= $(CPP_FILES:.cpp=.obj)
all: test_libFLAC++.exe
test_libFLAC++.exe: $(C_OBJS) $(CPP_OBJS)
link.exe /libpath:"..\..\obj\lib" -out:../../obj/bin/$*.exe $(CPP_OBJS) $(C_OBJS) libFLAC++.lib libFLAC.lib
link.exe /libpath:"..\..\obj\lib" -out:../../obj/bin/$*.exe $(CPP_OBJS) $(C_OBJS) libFLAC++.lib libFLAC.lib file_utils.lib
clean:
-del *.obj *.pch

View File

@@ -23,6 +23,7 @@ extern "C" {
#include "FLAC/assert.h"
#include "FLAC/metadata.h" // for ::FLAC__metadata_object_is_equal()
#include "FLAC++/decoder.h"
#include "share/file_utils.h"
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
@@ -2187,7 +2188,7 @@ bool test_decoders()
if(!test_file_decoder())
return false;
(void) file_utils__remove_file(flacfilename_);
(void) FLAC__file_utils_remove_file(flacfilename_);
free_metadata_blocks_();
return true;

View File

@@ -21,14 +21,7 @@
#include "FLAC/stream_encoder.h"
#include <stdio.h>
#include <stdlib.h>
#if defined _MSC_VER || defined __MINGW32__
#include <io.h> /* for chmod(), unlink */
#endif
#include <sys/stat.h> /* for stat(), chmod() */
#if defined _WIN32 && !defined __CYGWIN__
#else
#include <unistd.h> /* for unlink() */
#endif
#include <sys/stat.h> /* for stat() */
#ifdef min
#undef min
@@ -56,42 +49,6 @@ static void encoder_metadata_callback_(const FLAC__StreamEncoder *encoder, const
(void)encoder, (void)metadata, (void)client_data;
}
FLAC__bool file_utils__change_stats(const char *filename, FLAC__bool read_only)
{
struct stat stats;
if(0 == stat(filename, &stats)) {
#if !defined _MSC_VER && !defined __MINGW32__
if(read_only) {
stats.st_mode &= ~S_IWUSR;
stats.st_mode &= ~S_IWGRP;
stats.st_mode &= ~S_IWOTH;
}
else {
stats.st_mode |= S_IWUSR;
stats.st_mode |= S_IWGRP;
stats.st_mode |= S_IWOTH;
}
#else
if(read_only)
stats.st_mode &= ~S_IWRITE;
else
stats.st_mode |= S_IWRITE;
#endif
if(0 != chmod(filename, stats.st_mode))
return false;
}
else
return false;
return true;
}
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 *output_filesize, unsigned length, const FLAC__StreamMetadata *streaminfo, FLAC__StreamMetadata **metadata, unsigned num_metadata)
{
FLAC__int32 samples[1024];

View File

@@ -21,10 +21,6 @@
#include "FLAC/format.h"
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 *output_filesize, unsigned length, const FLAC__StreamMetadata *streaminfo, FLAC__StreamMetadata **metadata, unsigned num_metadata);
#endif

View File

@@ -22,6 +22,7 @@ extern "C" {
#include "FLAC/assert.h"
#include "FLAC++/decoder.h"
#include "FLAC++/metadata.h"
#include "share/file_utils.h"
#include <stdio.h>
#include <stdlib.h> /* for malloc() */
#include <string.h> /* for memcpy()/memset() */
@@ -362,8 +363,8 @@ static bool test_file_(const char *filename, bool ignore_metadata)
static bool change_stats_(const char *filename, bool read_only)
{
if(!file_utils__change_stats(filename, read_only))
return die_("during file_utils__change_stats()");
if(!FLAC__file_utils_change_stats(filename, read_only))
return die_("during FLAC__file_utils_change_stats()");
return true;
}
@@ -373,7 +374,7 @@ static bool remove_file_(const char *filename)
while(our_metadata_.num_blocks > 0)
delete_from_our_metadata_(0);
if(!file_utils__remove_file(filename))
if(!FLAC__file_utils_remove_file(filename))
return die_("removing file");
return true;

View File

@@ -23,7 +23,7 @@ topdir = ../..
PROGRAM_NAME = test_libFLAC
INCLUDES = -I../libFLAC/include -I$(topdir)/include
LIBS = -lFLAC -lm
LIBS = -lFLAC -lfile_utils -lm
OBJS = \
bitbuffer.o \
decoders.o \

View File

@@ -41,7 +41,7 @@ OBJS= $(C_FILES:.c=.obj)
all: test_libFLAC.exe
test_libFLAC.exe: $(OBJS)
link.exe /libpath:"..\..\obj\lib" -out:../../obj/bin/$*.exe $(OBJS) libFLAC.lib
link.exe /libpath:"..\..\obj\lib" -out:../../obj/bin/$*.exe $(OBJS) libFLAC.lib file_utils.lib
clean:
-del *.obj *.pch

View File

@@ -23,6 +23,7 @@
#include "FLAC/file_decoder.h"
#include "FLAC/seekable_stream_decoder.h"
#include "FLAC/stream_decoder.h"
#include "share/file_utils.h"
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
@@ -2075,7 +2076,7 @@ FLAC__bool test_decoders()
if(!test_file_decoder())
return false;
(void) file_utils__remove_file(flacfilename_);
(void) FLAC__file_utils_remove_file(flacfilename_);
free_metadata_blocks_();
return true;

View File

@@ -22,6 +22,7 @@
#include "FLAC/file_encoder.h"
#include "FLAC/seekable_stream_encoder.h"
#include "FLAC/stream_encoder.h"
#include "share/file_utils.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -1122,7 +1123,7 @@ FLAC__bool test_encoders()
if(!test_file_encoder())
return false;
(void) file_utils__remove_file(flacfilename_);
(void) FLAC__file_utils_remove_file(flacfilename_);
free_metadata_blocks_();
return true;

View File

@@ -21,14 +21,7 @@
#include "FLAC/stream_encoder.h"
#include <stdio.h>
#include <stdlib.h>
#if defined _MSC_VER || defined __MINGW32__
#include <io.h> /* for chmod(), unlink */
#endif
#include <sys/stat.h> /* for stat(), chmod() */
#if defined _WIN32 && !defined __CYGWIN__
#else
#include <unistd.h> /* for unlink() */
#endif
#include <sys/stat.h> /* for stat() */
#ifdef min
#undef min
@@ -56,42 +49,6 @@ static void encoder_metadata_callback_(const FLAC__StreamEncoder *encoder, const
(void)encoder, (void)metadata, (void)client_data;
}
FLAC__bool file_utils__change_stats(const char *filename, FLAC__bool read_only)
{
struct stat stats;
if(0 == stat(filename, &stats)) {
#if !defined _MSC_VER && !defined __MINGW32__
if(read_only) {
stats.st_mode &= ~S_IWUSR;
stats.st_mode &= ~S_IWGRP;
stats.st_mode &= ~S_IWOTH;
}
else {
stats.st_mode |= S_IWUSR;
stats.st_mode |= S_IWGRP;
stats.st_mode |= S_IWOTH;
}
#else
if(read_only)
stats.st_mode &= ~S_IWRITE;
else
stats.st_mode |= S_IWRITE;
#endif
if(0 != chmod(filename, stats.st_mode))
return false;
}
else
return false;
return true;
}
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 *output_filesize, unsigned length, const FLAC__StreamMetadata *streaminfo, FLAC__StreamMetadata **metadata, unsigned num_metadata)
{
FLAC__int32 samples[1024];

View File

@@ -21,10 +21,6 @@
#include "FLAC/format.h"
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 *output_filesize, unsigned length, const FLAC__StreamMetadata *streaminfo, FLAC__StreamMetadata **metadata, unsigned num_metadata);
#endif

View File

@@ -21,6 +21,7 @@
#include "FLAC/assert.h"
#include "FLAC/file_decoder.h"
#include "FLAC/metadata.h"
#include "share/file_utils.h"
#include <stdio.h>
#include <stdlib.h> /* for malloc() */
@@ -376,8 +377,8 @@ static FLAC__bool test_file_(const char *filename, void (*metadata_callback)(con
static FLAC__bool change_stats_(const char *filename, FLAC__bool read_only)
{
if(!file_utils__change_stats(filename, read_only))
return die_("during file_utils__change_stats()");
if(!FLAC__file_utils_change_stats(filename, read_only))
return die_("during FLAC__file_utils_change_stats()");
return true;
}
@@ -387,7 +388,7 @@ static FLAC__bool remove_file_(const char *filename)
while(our_metadata_.num_blocks > 0)
delete_from_our_metadata_(0);
if(!file_utils__remove_file(filename))
if(!FLAC__file_utils_remove_file(filename))
return die_("removing file");
return true;

View File

@@ -24,7 +24,7 @@ topdir = ../..
PROGRAM_NAME = test_libOggFLAC++
#@@@ TODO: conditionalize ogg lib path and -logg
INCLUDES = -I$(topdir)/include
LIBS = -lOggFLAC++ -lOggFLAC -lFLAC -L$(HOME)/local/lib -logg -lm
LIBS = -lOggFLAC++ -lOggFLAC -lFLAC -L$(HOME)/local/lib -logg -lfile_utils -lm
OBJS = \
decoders.o \
encoders.o \

View File

@@ -49,7 +49,7 @@ CPP_OBJS= $(CPP_FILES:.cpp=.obj)
all: test_libOggFLAC++.exe
test_libOggFLAC++.exe: $(C_OBJS) $(CPP_OBJS)
link.exe /libpath:"..\..\obj\lib" -out:../../obj/bin/$*.exe $(CPP_OBJS) $(C_OBJS) libOggFLAC++.lib libOggFLAC.lib libFLAC.lib ogg_static.lib
link.exe /libpath:"..\..\obj\lib" -out:../../obj/bin/$*.exe $(CPP_OBJS) $(C_OBJS) libOggFLAC++.lib libOggFLAC.lib libFLAC.lib ogg_static.lib file_utils.lib
clean:
-del *.obj *.pch

View File

@@ -23,6 +23,7 @@ extern "C" {
#include "FLAC/assert.h"
#include "FLAC/metadata.h" // for ::FLAC__metadata_object_is_equal()
#include "OggFLAC++/decoder.h"
#include "share/file_utils.h"
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
@@ -866,7 +867,7 @@ bool test_decoders()
if(!test_stream_decoder())
return false;
(void) file_utils__remove_file(oggflacfilename_);
(void) FLAC__file_utils_remove_file(oggflacfilename_);
free_metadata_blocks_();
return true;

View File

@@ -21,14 +21,7 @@
#include "OggFLAC/stream_encoder.h"
#include <stdio.h>
#include <stdlib.h>
#if defined _MSC_VER || defined __MINGW32__
#include <io.h> /* for chmod(), unlink */
#endif
#include <sys/stat.h> /* for stat(), chmod() */
#if defined _WIN32 && !defined __CYGWIN__
#else
#include <unistd.h> /* for unlink() */
#endif
#include <sys/stat.h> /* for stat() */
#ifdef min
#undef min
@@ -53,42 +46,6 @@ static FLAC__StreamEncoderWriteStatus encoder_write_callback_(const OggFLAC__Str
return FLAC__STREAM_ENCODER_WRITE_STATUS_OK;
}
FLAC__bool file_utils__change_stats(const char *filename, FLAC__bool read_only)
{
struct stat stats;
if(0 == stat(filename, &stats)) {
#if !defined _MSC_VER && !defined __MINGW32__
if(read_only) {
stats.st_mode &= ~S_IWUSR;
stats.st_mode &= ~S_IWGRP;
stats.st_mode &= ~S_IWOTH;
}
else {
stats.st_mode |= S_IWUSR;
stats.st_mode |= S_IWGRP;
stats.st_mode |= S_IWOTH;
}
#else
if(read_only)
stats.st_mode &= ~S_IWRITE;
else
stats.st_mode |= S_IWRITE;
#endif
if(0 != chmod(filename, stats.st_mode))
return false;
}
else
return false;
return true;
}
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_oggflacfile(const char *output_filename, unsigned *output_filesize, unsigned length, const FLAC__StreamMetadata *streaminfo, FLAC__StreamMetadata **metadata, unsigned num_metadata)
{
FLAC__int32 samples[1024];

View File

@@ -23,10 +23,6 @@
extern const long file_utils__serial_number;
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_oggflacfile(const char *output_filename, unsigned *output_filesize, unsigned length, const FLAC__StreamMetadata *streaminfo, FLAC__StreamMetadata **metadata, unsigned num_metadata);
#endif

View File

@@ -24,7 +24,7 @@ topdir = ../..
PROGRAM_NAME = test_libOggFLAC
#@@@ TODO: conditionalize ogg lib path and -logg
INCLUDES = -I$(topdir)/include
LIBS = -lOggFLAC -lFLAC -lm -L$(HOME)/local/lib -logg
LIBS = -lOggFLAC -lFLAC -L$(HOME)/local/lib -logg -lfile_utils -lm
OBJS = \
decoders.o \
encoders.o \

View File

@@ -37,7 +37,7 @@ OBJS= $(C_FILES:.c=.obj)
all: test_libOggFLAC.exe
test_libOggFLAC.exe: $(OBJS)
link.exe /libpath:"..\..\obj\lib" -out:../../obj/bin/$*.exe $(OBJS) libOggFLAC.lib libFLAC.lib ogg_static.lib
link.exe /libpath:"..\..\obj\lib" -out:../../obj/bin/$*.exe $(OBJS) libOggFLAC.lib libFLAC.lib ogg_static.lib file_utils.lib
clean:
-del *.obj *.pch

View File

@@ -21,6 +21,7 @@
#include "metadata_utils.h"
#include "FLAC/assert.h"
#include "OggFLAC/stream_decoder.h"
#include "share/file_utils.h"
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
@@ -814,7 +815,7 @@ FLAC__bool test_decoders()
if(!test_stream_decoder())
return false;
(void) file_utils__remove_file(oggflacfilename_);
(void) FLAC__file_utils_remove_file(oggflacfilename_);
free_metadata_blocks_();
return true;

View File

@@ -20,6 +20,7 @@
#include "file_utils.h"
#include "FLAC/assert.h"
#include "OggFLAC/stream_encoder.h"
#include "share/file_utils.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -450,7 +451,7 @@ FLAC__bool test_encoders()
if(!test_stream_encoder())
return false;
(void) file_utils__remove_file(oggflacfilename_);
(void) FLAC__file_utils_remove_file(oggflacfilename_);
free_metadata_blocks_();
return true;

View File

@@ -21,14 +21,7 @@
#include "OggFLAC/stream_encoder.h"
#include <stdio.h>
#include <stdlib.h>
#if defined _MSC_VER || defined __MINGW32__
#include <io.h> /* for chmod(), unlink */
#endif
#include <sys/stat.h> /* for stat(), chmod() */
#if defined _WIN32 && !defined __CYGWIN__
#else
#include <unistd.h> /* for unlink() */
#endif
#include <sys/stat.h> /* for stat() */
#ifdef min
#undef min
@@ -53,42 +46,6 @@ static FLAC__StreamEncoderWriteStatus encoder_write_callback_(const OggFLAC__Str
return FLAC__STREAM_ENCODER_WRITE_STATUS_OK;
}
FLAC__bool file_utils__change_stats(const char *filename, FLAC__bool read_only)
{
struct stat stats;
if(0 == stat(filename, &stats)) {
#if !defined _MSC_VER && !defined __MINGW32__
if(read_only) {
stats.st_mode &= ~S_IWUSR;
stats.st_mode &= ~S_IWGRP;
stats.st_mode &= ~S_IWOTH;
}
else {
stats.st_mode |= S_IWUSR;
stats.st_mode |= S_IWGRP;
stats.st_mode |= S_IWOTH;
}
#else
if(read_only)
stats.st_mode &= ~S_IWRITE;
else
stats.st_mode |= S_IWRITE;
#endif
if(0 != chmod(filename, stats.st_mode))
return false;
}
else
return false;
return true;
}
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_oggflacfile(const char *output_filename, unsigned *output_filesize, unsigned length, const FLAC__StreamMetadata *streaminfo, FLAC__StreamMetadata **metadata, unsigned num_metadata)
{
FLAC__int32 samples[1024];

View File

@@ -23,10 +23,6 @@
extern const long file_utils__serial_number;
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_oggflacfile(const char *output_filename, unsigned *output_filesize, unsigned length, const FLAC__StreamMetadata *streaminfo, FLAC__StreamMetadata **metadata, unsigned num_metadata);
#endif