1*600f14f4SXin Li /* grabbag - Convenience lib for various routines common to several tools 2*600f14f4SXin Li * Copyright (C) 2002-2009 Josh Coalson 3*600f14f4SXin Li * Copyright (C) 2011-2023 Xiph.Org Foundation 4*600f14f4SXin Li * 5*600f14f4SXin Li * This library is free software; you can redistribute it and/or 6*600f14f4SXin Li * modify it under the terms of the GNU Lesser General Public 7*600f14f4SXin Li * License as published by the Free Software Foundation; either 8*600f14f4SXin Li * version 2.1 of the License, or (at your option) any later version. 9*600f14f4SXin Li * 10*600f14f4SXin Li * This library is distributed in the hope that it will be useful, 11*600f14f4SXin Li * but WITHOUT ANY WARRANTY; without even the implied warranty of 12*600f14f4SXin Li * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13*600f14f4SXin Li * Lesser General Public License for more details. 14*600f14f4SXin Li * 15*600f14f4SXin Li * You should have received a copy of the GNU Lesser General Public 16*600f14f4SXin Li * License along with this library; if not, write to the Free Software 17*600f14f4SXin Li * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18*600f14f4SXin Li */ 19*600f14f4SXin Li 20*600f14f4SXin Li /* Convenience routines for manipulating files */ 21*600f14f4SXin Li 22*600f14f4SXin Li /* This .h cannot be included by itself; #include "share/grabbag.h" instead. */ 23*600f14f4SXin Li 24*600f14f4SXin Li #ifndef GRABAG__FILE_H 25*600f14f4SXin Li #define GRABAG__FILE_H 26*600f14f4SXin Li 27*600f14f4SXin Li /* needed because of off_t */ 28*600f14f4SXin Li #ifdef HAVE_CONFIG_H 29*600f14f4SXin Li # include <config.h> 30*600f14f4SXin Li #endif 31*600f14f4SXin Li 32*600f14f4SXin Li #include <sys/types.h> /* for off_t */ 33*600f14f4SXin Li #include <stdio.h> /* for FILE */ 34*600f14f4SXin Li #include "FLAC/ordinals.h" 35*600f14f4SXin Li #include "share/compat.h" 36*600f14f4SXin Li 37*600f14f4SXin Li #ifdef __cplusplus 38*600f14f4SXin Li extern "C" { 39*600f14f4SXin Li #endif 40*600f14f4SXin Li 41*600f14f4SXin Li void grabbag__file_copy_metadata(const char *srcpath, const char *destpath); 42*600f14f4SXin Li FLAC__off_t grabbag__file_get_filesize(const char *srcpath); 43*600f14f4SXin Li const char *grabbag__file_get_basename(const char *srcpath); 44*600f14f4SXin Li 45*600f14f4SXin Li /* read_only == false means "make file writable by user" 46*600f14f4SXin Li * read_only == true means "make file read-only for everyone" 47*600f14f4SXin Li */ 48*600f14f4SXin Li FLAC__bool grabbag__file_change_stats(const char *filename, FLAC__bool read_only); 49*600f14f4SXin Li 50*600f14f4SXin Li /* returns true iff stat() succeeds for both files and they have the same device and inode. */ 51*600f14f4SXin Li /* on windows, uses GetFileInformationByHandle() to compare */ 52*600f14f4SXin Li FLAC__bool grabbag__file_are_same(const char *f1, const char *f2); 53*600f14f4SXin Li 54*600f14f4SXin Li /* attempts to make writable before unlinking */ 55*600f14f4SXin Li FLAC__bool grabbag__file_remove_file(const char *filename); 56*600f14f4SXin Li 57*600f14f4SXin Li /* these will forcibly set stdin/stdout to binary mode (for OSes that require it) */ 58*600f14f4SXin Li FILE *grabbag__file_get_binary_stdin(void); 59*600f14f4SXin Li FILE *grabbag__file_get_binary_stdout(void); 60*600f14f4SXin Li 61*600f14f4SXin Li #ifdef __cplusplus 62*600f14f4SXin Li } 63*600f14f4SXin Li #endif 64*600f14f4SXin Li 65*600f14f4SXin Li #endif 66