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../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;