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