Blame include/file_change_detection.h

Packit Bot fdffc7
/* Detecting file changes using modification times.
Packit Bot fdffc7
   Copyright (C) 2017-2020 Free Software Foundation, Inc.
Packit Bot fdffc7
   This file is part of the GNU C Library.
Packit Bot fdffc7
Packit Bot fdffc7
   The GNU C Library is free software; you can redistribute it and/or
Packit Bot fdffc7
   modify it under the terms of the GNU Lesser General Public
Packit Bot fdffc7
   License as published by the Free Software Foundation; either
Packit Bot fdffc7
   version 2.1 of the License, or (at your option) any later version.
Packit Bot fdffc7
Packit Bot fdffc7
   The GNU C Library is distributed in the hope that it will be useful,
Packit Bot fdffc7
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Bot fdffc7
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Bot fdffc7
   Lesser General Public License for more details.
Packit Bot fdffc7
Packit Bot fdffc7
   You should have received a copy of the GNU Lesser General Public
Packit Bot fdffc7
   License along with the GNU C Library; if not, see
Packit Bot fdffc7
   <https://www.gnu.org/licenses/>.  */
Packit Bot fdffc7
Packit Bot 9ac4d5
#ifndef _FILE_CHANGE_DETECTION_H
Packit Bot 9ac4d5
#define _FILE_CHANGE_DETECTION_H
Packit Bot 9ac4d5
Packit Bot fdffc7
#include <stdbool.h>
Packit Bot fdffc7
#include <stdio.h>
Packit Bot fdffc7
#include <sys/stat.h>
Packit Bot fdffc7
#include <sys/types.h>
Packit Bot fdffc7
Packit Bot fdffc7
/* Items for identifying a particular file version.  Excerpt from
Packit Bot fdffc7
   struct stat64.  */
Packit Bot fdffc7
struct file_change_detection
Packit Bot fdffc7
{
Packit Bot fdffc7
  /* Special values: 0 if file does not exist.  -1 to force mismatch
Packit Bot fdffc7
     with the next comparison.  */
Packit Bot fdffc7
  off64_t size;
Packit Bot fdffc7
Packit Bot fdffc7
  ino64_t ino;
Packit Bot fdffc7
  struct timespec mtime;
Packit Bot fdffc7
  struct timespec ctime;
Packit Bot fdffc7
};
Packit Bot fdffc7
Packit Bot fdffc7
/* Returns true if *LEFT and *RIGHT describe the same version of the
Packit Bot fdffc7
   same file.  */
Packit Bot 9ac4d5
bool __file_is_unchanged (const struct file_change_detection *left,
Packit Bot 9ac4d5
                          const struct file_change_detection *right);
Packit Bot fdffc7
Packit Bot fdffc7
/* Extract file change information to *FILE from the stat buffer
Packit Bot fdffc7
   *ST.  */
Packit Bot 9ac4d5
void __file_change_detection_for_stat (struct file_change_detection *file,
Packit Bot 9ac4d5
                                       const struct stat64 *st);
Packit Bot fdffc7
Packit Bot fdffc7
/* Writes file change information for PATH to *FILE.  Returns true on
Packit Bot fdffc7
   success.  For benign errors, *FILE is cleared, and true is
Packit Bot fdffc7
   returned.  For errors indicating resource outages and the like,
Packit Bot fdffc7
   false is returned.  */
Packit Bot 9ac4d5
bool __file_change_detection_for_path (struct file_change_detection *file,
Packit Bot 9ac4d5
                                       const char *path);
Packit Bot fdffc7
Packit Bot fdffc7
/* Writes file change information for the stream FP to *FILE.  Returns
Packit Bot fdffc7
   ture on success, false on failure.  If FP is NULL, treat the file
Packit Bot fdffc7
   as non-existing.  */
Packit Bot 9ac4d5
bool __file_change_detection_for_fp (struct file_change_detection *file,
Packit Bot 9ac4d5
                                     FILE *fp);
Packit Bot 9ac4d5
Packit Bot 9ac4d5
#ifndef _ISOMAC
Packit Bot 9ac4d5
libc_hidden_proto (__file_is_unchanged)
Packit Bot 9ac4d5
libc_hidden_proto (__file_change_detection_for_stat)
Packit Bot 9ac4d5
libc_hidden_proto (__file_change_detection_for_path)
Packit Bot 9ac4d5
libc_hidden_proto (__file_change_detection_for_fp)
Packit Bot 9ac4d5
#endif
Packit Bot 9ac4d5
Packit Bot 9ac4d5
#endif /* _FILE_CHANGE_DETECTION_H */