file.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /* grabbag - Convenience lib for various routines common to several tools
  2. * Copyright (C) 2002-2009 Josh Coalson
  3. * Copyright (C) 2011-2023 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. /* Convenience routines for manipulating files */
  20. /* This .h cannot be included by itself; #include "share/grabbag.h" instead. */
  21. #ifndef GRABAG__FILE_H
  22. #define GRABAG__FILE_H
  23. /* needed because of off_t */
  24. #ifdef HAVE_CONFIG_H
  25. # include <config.h>
  26. #endif
  27. #include <sys/types.h> /* for off_t */
  28. #include <stdio.h> /* for FILE */
  29. #include "FLAC/ordinals.h"
  30. #include "share/compat.h"
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34. void grabbag__file_copy_metadata(const char *srcpath, const char *destpath);
  35. FLAC__off_t grabbag__file_get_filesize(const char *srcpath);
  36. const char *grabbag__file_get_basename(const char *srcpath);
  37. /* read_only == false means "make file writable by user"
  38. * read_only == true means "make file read-only for everyone"
  39. */
  40. FLAC__bool grabbag__file_change_stats(const char *filename, FLAC__bool read_only);
  41. /* returns true iff stat() succeeds for both files and they have the same device and inode. */
  42. /* on windows, uses GetFileInformationByHandle() to compare */
  43. FLAC__bool grabbag__file_are_same(const char *f1, const char *f2);
  44. /* attempts to make writable before unlinking */
  45. FLAC__bool grabbag__file_remove_file(const char *filename);
  46. /* these will forcibly set stdin/stdout to binary mode (for OSes that require it) */
  47. FILE *grabbag__file_get_binary_stdin(void);
  48. FILE *grabbag__file_get_binary_stdout(void);
  49. #ifdef __cplusplus
  50. }
  51. #endif
  52. #endif