file.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * libdpkg - Debian packaging suite library routines
  3. * file.h - file handling routines
  4. *
  5. * Copyright © 2008-2010 Guillem Jover <guillem@debian.org>
  6. *
  7. * This is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  19. */
  20. #ifndef LIBDPKG_FILE_H
  21. #define LIBDPKG_FILE_H
  22. #include <sys/types.h>
  23. #include <stdbool.h>
  24. #include <dpkg/macros.h>
  25. DPKG_BEGIN_DECLS
  26. /**
  27. * @defgroup file File handling
  28. * @ingroup dpkg-internal
  29. * @{
  30. */
  31. struct file_stat {
  32. uid_t uid;
  33. gid_t gid;
  34. mode_t mode;
  35. };
  36. void file_copy_perms(const char *src, const char *dst);
  37. enum file_lock_flags {
  38. FILE_LOCK_NOWAIT,
  39. FILE_LOCK_WAIT,
  40. };
  41. bool file_is_locked(int lockfd, const char *filename);
  42. void file_lock(int *lockfd, enum file_lock_flags flags, const char *filename,
  43. const char *desc);
  44. void file_unlock(int fd, const char *desc);
  45. void file_show(const char *filename);
  46. /** @} */
  47. DPKG_END_DECLS
  48. #endif /* LIBDPKG_FILE_H */