--- /dev/null
+/* file_utils - Convenience lib for manipulating file stats
+ * Copyright (C) 2002 Josh Coalson
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+/*
+ * This wraps the gain_analysis lib, which is LGPL. This wrapper
+ * allows analysis of different input resolutions by automatically
+ * scaling the input signal
+ */
+
+#ifndef FLAC__SHARE__FILE_UTILS_H
+#define FLAC__SHARE__FILE_UTILS_H
+
+#if defined(FLAC__NO_DLL) || defined(unix) || defined(__CYGWIN__) || defined(__CYGWIN32__)
+#define FILE_UTILS_API
+
+#else
+
+#ifdef FILE_UTILS_API_EXPORTS
+#define FILE_UTILS_API _declspec(dllexport)
+#else
+#define FILE_UTILS_API _declspec(dllimport)
+#define __LIBNAME__ "file_utils.lib"
+#pragma comment(lib, __LIBNAME__)
+#undef __LIBNAME__
+
+#endif
+#endif
+
+#include <sys/types.h> /* for off_t */
+#include <stdio.h> /* for FILE */
+#include "FLAC/ordinals.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+FILE_UTILS_API void FLAC__file_utils_copy_metadata(const char *srcpath, const char *destpath);
+FILE_UTILS_API off_t FLAC__file_utils_get_filesize(const char *srcpath);
+FILE_UTILS_API const char *FLAC__file_utils_get_basename(const char *srcpath);
+
+/* read_only == false means "make file writable by user"
+ * read_only == true means "make file read-only for everyone"
+ */
+FILE_UTILS_API FLAC__bool FLAC__file_utils_change_stats(const char *filename, FLAC__bool read_only);
+
+/* attempts to make writable before unlinking */
+FILE_UTILS_API FLAC__bool FLAC__file_utils_remove_file(const char *filename);
+
+/* these will forcibly set stdin/stdout to binary mode (for OSes that require it) */
+FILE_UTILS_API FILE *FLAC__file_utils_get_binary_stdin();
+FILE_UTILS_API FILE *FLAC__file_utils_get_binary_stdout();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
--- /dev/null
+## Process this file with automake to produce Makefile.in
+
+AUTOMAKE_OPTIONS = foreign
+
+INCLUDES = -I$(top_srcdir)/include
+
+noinst_LIBRARIES = libfile_utils.a
+
+libfile_utils_a_SOURCES = file_utils.c
+
+EXTRA_DIST = \
+ Makefile.lite \
+ Makefile.vc \
+ file_utils.dsp
+
+debug:
+ $(MAKE) all CFLAGS="@DEBUG@"
+
+profile:
+ $(MAKE) all CFLAGS="@PROFILE@"
--- /dev/null
+#
+# GNU makefile
+#
+
+topdir = ../../..
+
+LIB_NAME = libfile_utils
+INCLUDES = -I$(topdir)/include
+
+OBJS = \
+ file_utils.o
+
+include $(topdir)/build/lib.mk
+
+# DO NOT DELETE THIS LINE -- make depend depends on it.
--- /dev/null
+!include <win32.mak>\r
+\r
+!IFDEF DEBUG\r
+.c.obj:\r
+ $(cc) /D "_LIB" -DFLAC__NO_DLL /GX $(cdebug) $(cflags) /I "..\..\..\include" -DSTRICT -YX /Od /D "_DEBUG" $<\r
+!else\r
+.c.obj:\r
+ $(cc) /D "_LIB" -DFLAC__NO_DLL /O2 $(crelease) $(cflags) /I "..\..\..\include" -DSTRICT -YX -DNODEBUG $<\r
+!endif\r
+\r
+C_FILES= \\r
+ file_utils.c \\r
+\r
+OBJS= $(C_FILES:.c=.obj)\r
+\r
+all: file_utils.lib\r
+\r
+file_utils.lib: $(OBJS)\r
+ link.exe -lib /nodefaultlib -out:../../../obj/lib/$*.lib $(OBJS)\r
+\r
+clean:\r
+ -del *.obj *.pch\r
+ -del ..\..\..\obj\lib\file_utils.lib ..\..\..\obj\lib\file_utils.pdb\r
--- /dev/null
+/* file_utils - Convenience lib for manipulating file stats
+ * Copyright (C) 2002 Josh Coalson
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#if defined _MSC_VER || defined __MINGW32__
+#include <sys/utime.h> /* for utime() */
+#include <io.h> /* for chmod(), _setmode(), unlink() */
+#include <fcntl.h> /* for _O_BINARY */
+#else
+#include <sys/types.h> /* some flavors of BSD (like OS X) require this to get time_t */
+#include <utime.h> /* for utime() */
+#endif
+#ifdef __CYGWIN__
+#include <io.h> /* for setmode(), O_BINARY */
+#include <fcntl.h> /* for _O_BINARY */
+#endif
+#include <sys/stat.h> /* for stat(), maybe chmod() */
+#if defined _WIN32 && !defined __CYGWIN__
+#else
+#include <unistd.h> /* for unlink() */
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h> /* for strrchr() */
+#include "share/file_utils.h"
+
+
+FILE_UTILS_API void FLAC__file_utils_copy_metadata(const char *srcpath, const char *destpath)
+{
+ struct stat srcstat;
+ struct utimbuf srctime;
+
+ if(0 == stat(srcpath, &srcstat)) {
+ srctime.actime = srcstat.st_atime;
+ srctime.modtime = srcstat.st_mtime;
+ (void)chmod(destpath, srcstat.st_mode);
+ (void)utime(destpath, &srctime);
+ }
+}
+
+FILE_UTILS_API off_t FLAC__file_utils_get_filesize(const char *srcpath)
+{
+ struct stat srcstat;
+
+ if(0 == stat(srcpath, &srcstat))
+ return srcstat.st_size;
+ else
+ return -1;
+}
+
+FILE_UTILS_API const char *FLAC__file_utils_get_basename(const char *srcpath)
+{
+ const char *p;
+
+ p = strrchr(srcpath, '/');
+ if(0 == p) {
+ p = strrchr(srcpath, '\\');
+ if(0 == p)
+ return srcpath;
+ }
+ return ++p;
+}
+
+FILE_UTILS_API FLAC__bool FLAC__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;
+ }
+#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;
+}
+
+FILE_UTILS_API FLAC__bool FLAC__file_utils_remove_file(const char *filename)
+{
+ return FLAC__file_utils_change_stats(filename, /*read_only=*/false) && 0 == unlink(filename);
+}
+
+FILE_UTILS_API FILE *FLAC__file_utils_get_binary_stdin()
+{
+ /* if something breaks here it is probably due to the presence or
+ * absence of an underscore before the identifiers 'setmode',
+ * 'fileno', and/or 'O_BINARY'; check your system header files.
+ */
+#if defined _MSC_VER || defined __MINGW32__
+ _setmode(_fileno(stdin), _O_BINARY);
+#elif defined __CYGWIN__
+ /* almost certainly not needed for any modern Cygwin, but let's be safe... */
+ setmode(_fileno(stdin), _O_BINARY);
+#endif
+
+ return stdin;
+}
+
+FILE_UTILS_API FILE *FLAC__file_utils_get_binary_stdout()
+{
+ /* if something breaks here it is probably due to the presence or
+ * absence of an underscore before the identifiers 'setmode',
+ * 'fileno', and/or 'O_BINARY'; check your system header files.
+ */
+#if defined _MSC_VER || defined __MINGW32__
+ _setmode(_fileno(stdout), _O_BINARY);
+#elif defined __CYGWIN__
+ /* almost certainly not needed for any modern Cygwin, but let's be safe... */
+ setmode(_fileno(stdout), _O_BINARY);
+#endif
+
+ return stdout;
+}
--- /dev/null
+# Microsoft Developer Studio Project File - Name="file_utils" - Package Owner=<4>\r
+# Microsoft Developer Studio Generated Build File, Format Version 6.00\r
+# ** DO NOT EDIT **\r
+\r
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102\r
+\r
+CFG=file_utils - Win32 Debug\r
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r
+!MESSAGE use the Export Makefile command and run\r
+!MESSAGE \r
+!MESSAGE NMAKE /f "file_utils.mak".\r
+!MESSAGE \r
+!MESSAGE You can specify a configuration when running NMAKE\r
+!MESSAGE by defining the macro CFG on the command line. For example:\r
+!MESSAGE \r
+!MESSAGE NMAKE /f "file_utils.mak" CFG="file_utils - Win32 Debug"\r
+!MESSAGE \r
+!MESSAGE Possible choices for configuration are:\r
+!MESSAGE \r
+!MESSAGE "file_utils - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")\r
+!MESSAGE "file_utils - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")\r
+!MESSAGE \r
+\r
+# Begin Project\r
+# PROP AllowPerConfigDependencies 0\r
+# PROP Scc_ProjName "file_utils"\r
+# PROP Scc_LocalPath "..\..\.."\r
+CPP=cl.exe\r
+MTL=midl.exe\r
+RSC=rc.exe\r
+\r
+!IF "$(CFG)" == "file_utils - Win32 Release"\r
+\r
+# PROP BASE Use_MFC 0\r
+# PROP BASE Use_Debug_Libraries 0\r
+# PROP BASE Output_Dir "Release"\r
+# PROP BASE Intermediate_Dir "Release"\r
+# PROP BASE Target_Dir ""\r
+# PROP Use_MFC 0\r
+# PROP Use_Debug_Libraries 0\r
+# PROP Output_Dir "..\..\..\obj\lib"\r
+# PROP Intermediate_Dir "Release"\r
+# PROP Ignore_Export_Lib 0\r
+# PROP Target_Dir ""\r
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c\r
+# ADD CPP /nologo /MD /W3 /GR /GX /O2 /I ".\include" /I "..\..\..\include" /D "NDEBUG" /D "REPLAYGAIN_API_EXPORTS" /D "_WINDOWS" /D "_WINDLL" /D "WIN32" /D "_USRDLL" /FR /FD /c\r
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32\r
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32\r
+# ADD BASE RSC /l 0x409 /d "NDEBUG"\r
+# ADD RSC /l 0x409 /d "NDEBUG" /d "_USRDLL"\r
+BSC32=bscmake.exe\r
+# ADD BASE BSC32 /nologo\r
+# ADD BSC32 /nologo\r
+LINK32=link.exe\r
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386\r
+# ADD LINK32 /nologo /subsystem:windows /dll /machine:I386 /out:"..\..\..\obj\bin/file_utils.dll"\r
+\r
+!ELSEIF "$(CFG)" == "file_utils - Win32 Debug"\r
+\r
+# PROP BASE Use_MFC 0\r
+# PROP BASE Use_Debug_Libraries 1\r
+# PROP BASE Output_Dir "Debug"\r
+# PROP BASE Intermediate_Dir "Debug"\r
+# PROP BASE Target_Dir ""\r
+# PROP Use_MFC 0\r
+# PROP Use_Debug_Libraries 1\r
+# PROP Output_Dir "..\..\..\obj\lib"\r
+# PROP Intermediate_Dir "Debug"\r
+# PROP Ignore_Export_Lib 0\r
+# PROP Target_Dir ""\r
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c\r
+# ADD CPP /nologo /MDd /W3 /Gm /GR /GX /ZI /Od /I ".\include" /I "..\..\..\include" /D "_DEBUG" /D "_CHATTER" /D "REPLAYGAIN_API_EXPORTS" /D "_WINDOWS" /D "_WINDLL" /D "WIN32" /D "_USRDLL" /FR /FD /c\r
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32\r
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32\r
+# ADD BASE RSC /l 0x409 /d "_DEBUG"\r
+# ADD RSC /l 0x409 /d "_DEBUG" /d "_USRDLL"\r
+BSC32=bscmake.exe\r
+# ADD BASE BSC32 /nologo\r
+# ADD BSC32 /nologo\r
+LINK32=link.exe\r
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept\r
+# ADD LINK32 /nologo /subsystem:windows /dll /debug /machine:I386 /out:"..\..\..\obj\bin/file_utils.dll" /pdbtype:sept\r
+\r
+!ENDIF \r
+\r
+# Begin Target\r
+\r
+# Name "file_utils - Win32 Release"\r
+# Name "file_utils - Win32 Debug"\r
+# Begin Group "Source Files"\r
+\r
+# PROP Default_Filter "cpp"\r
+# Begin Source File\r
+\r
+SOURCE=.\file_utils.c\r
+# End Source File\r
+# End Group\r
+# Begin Group "Private Header Files"\r
+\r
+# PROP Default_Filter ""\r
+# End Group\r
+# Begin Group "Protected Header Files"\r
+\r
+# PROP Default_Filter ""\r
+# End Group\r
+# Begin Group "Public Header Files"\r
+\r
+# PROP Default_Filter ""\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\share\file_utils.h\r
+# End Source File\r
+# End Group\r
+# End Target\r
+# End Project\r