1 /* Detecting file changes using modification times.
2 Copyright (C) 2017-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C 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.
10 The GNU C 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.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
19 #ifndef _FILE_CHANGE_DETECTION_H
20 #define _FILE_CHANGE_DETECTION_H
25 #include <sys/types.h>
27 /* Items for identifying a particular file version. Excerpt from
29 struct file_change_detection
31 /* Special values: 0 if file does not exist. -1 to force mismatch
32 with the next comparison. */
36 struct __timespec64 mtime
;
37 struct __timespec64 ctime
;
40 /* Returns true if *LEFT and *RIGHT describe the same version of the
42 bool __file_is_unchanged (const struct file_change_detection
*left
,
43 const struct file_change_detection
*right
);
45 /* Extract file change information to *FILE from the stat buffer
47 void __file_change_detection_for_stat (struct file_change_detection
*file
,
48 const struct __stat64_t64
*st
);
50 /* Writes file change information for PATH to *FILE. Returns true on
51 success. For benign errors, *FILE is cleared, and true is
52 returned. For errors indicating resource outages and the like,
54 bool __file_change_detection_for_path (struct file_change_detection
*file
,
57 /* Writes file change information for the stream FP to *FILE. Returns
58 true on success, false on failure. If FP is NULL, treat the file
60 bool __file_change_detection_for_fp (struct file_change_detection
*file
,
64 libc_hidden_proto (__file_is_unchanged
)
65 libc_hidden_proto (__file_change_detection_for_stat
)
66 libc_hidden_proto (__file_change_detection_for_path
)
67 libc_hidden_proto (__file_change_detection_for_fp
)
70 #endif /* _FILE_CHANGE_DETECTION_H */