Mercurial > hg > octave-kai > gnulib-hg
annotate lib/stat-time.h @ 17028:ce2683fe3994
Keep the extern-inline macros closer together.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Wed, 01 Aug 2012 14:30:54 -0700 |
parents | fc49ecfa5827 |
children | e542fd46ad6f |
rev | line source |
---|---|
6237
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
1 /* stat-related time functions. |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
2 |
16201
8250f2777afc
maint: update all copyright year number ranges
Jim Meyering <meyering@redhat.com>
parents:
14890
diff
changeset
|
3 Copyright (C) 2005, 2007, 2009-2012 Free Software Foundation, Inc. |
6237
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
4 |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8621
diff
changeset
|
5 This program is free software: you can redistribute it and/or modify |
6237
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
6 it under the terms of the GNU General Public License as published by |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8621
diff
changeset
|
7 the Free Software Foundation; either version 3 of the License, or |
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8621
diff
changeset
|
8 (at your option) any later version. |
6237
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
9 |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
10 This program is distributed in the hope that it will be useful, |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
13 GNU General Public License for more details. |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
14 |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
15 You should have received a copy of the GNU General Public License |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8621
diff
changeset
|
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
6237
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
17 |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
18 /* Written by Paul Eggert. */ |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
19 |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
20 #ifndef STAT_TIME_H |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
21 #define STAT_TIME_H 1 |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
22 |
8565
c49cf515502f
2007-03-27 Bruno Haible <bruno@clisp.org>
Bruno Haible <bruno@clisp.org>
parents:
8223
diff
changeset
|
23 #include <sys/stat.h> |
8223
ca249819379f
* lib/getdate.h (includes): Include <time.h>, not "timespec.h".
Eric Blake <ebb9@byu.net>
parents:
6471
diff
changeset
|
24 #include <time.h> |
6237
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
25 |
17023
fc49ecfa5827
stat-time: use extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents:
16242
diff
changeset
|
26 _GL_INLINE_HEADER_BEGIN |
17028
ce2683fe3994
Keep the extern-inline macros closer together.
Paul Eggert <eggert@cs.ucla.edu>
parents:
17023
diff
changeset
|
27 #ifndef _GL_STAT_TIME_INLINE |
ce2683fe3994
Keep the extern-inline macros closer together.
Paul Eggert <eggert@cs.ucla.edu>
parents:
17023
diff
changeset
|
28 # define _GL_STAT_TIME_INLINE _GL_INLINE |
ce2683fe3994
Keep the extern-inline macros closer together.
Paul Eggert <eggert@cs.ucla.edu>
parents:
17023
diff
changeset
|
29 #endif |
17023
fc49ecfa5827
stat-time: use extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents:
16242
diff
changeset
|
30 |
6237
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
31 /* STAT_TIMESPEC (ST, ST_XTIM) is the ST_XTIM member for *ST of type |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
32 struct timespec, if available. If not, then STAT_TIMESPEC_NS (ST, |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
33 ST_XTIM) is the nanosecond component of the ST_XTIM member for *ST, |
8568
392970b32717
Support sub-second birthtime on cygwin.
Eric Blake <ebb9@byu.net>
parents:
8567
diff
changeset
|
34 if available. ST_XTIM can be st_atim, st_ctim, st_mtim, or st_birthtim |
392970b32717
Support sub-second birthtime on cygwin.
Eric Blake <ebb9@byu.net>
parents:
8567
diff
changeset
|
35 for access, status change, data modification, or birth (creation) |
392970b32717
Support sub-second birthtime on cygwin.
Eric Blake <ebb9@byu.net>
parents:
8567
diff
changeset
|
36 time respectively. |
6237
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
37 |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
38 These macros are private to stat-time.h. */ |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
39 #if defined HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC |
6471
54a70822331f
* m4/stat-time.m4 (STATE_TIMESPEC, STAT_TIMESPEC_NS): Add check for
Paul Eggert <eggert@cs.ucla.edu>
parents:
6242
diff
changeset
|
40 # ifdef TYPEOF_STRUCT_STAT_ST_ATIM_IS_STRUCT_TIMESPEC |
54a70822331f
* m4/stat-time.m4 (STATE_TIMESPEC, STAT_TIMESPEC_NS): Add check for
Paul Eggert <eggert@cs.ucla.edu>
parents:
6242
diff
changeset
|
41 # define STAT_TIMESPEC(st, st_xtim) ((st)->st_xtim) |
54a70822331f
* m4/stat-time.m4 (STATE_TIMESPEC, STAT_TIMESPEC_NS): Add check for
Paul Eggert <eggert@cs.ucla.edu>
parents:
6242
diff
changeset
|
42 # else |
54a70822331f
* m4/stat-time.m4 (STATE_TIMESPEC, STAT_TIMESPEC_NS): Add check for
Paul Eggert <eggert@cs.ucla.edu>
parents:
6242
diff
changeset
|
43 # define STAT_TIMESPEC_NS(st, st_xtim) ((st)->st_xtim.tv_nsec) |
54a70822331f
* m4/stat-time.m4 (STATE_TIMESPEC, STAT_TIMESPEC_NS): Add check for
Paul Eggert <eggert@cs.ucla.edu>
parents:
6242
diff
changeset
|
44 # endif |
6237
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
45 #elif defined HAVE_STRUCT_STAT_ST_ATIMESPEC_TV_NSEC |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
46 # define STAT_TIMESPEC(st, st_xtim) ((st)->st_xtim##espec) |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
47 #elif defined HAVE_STRUCT_STAT_ST_ATIMENSEC |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
48 # define STAT_TIMESPEC_NS(st, st_xtim) ((st)->st_xtim##ensec) |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
49 #elif defined HAVE_STRUCT_STAT_ST_ATIM_ST__TIM_TV_NSEC |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
50 # define STAT_TIMESPEC_NS(st, st_xtim) ((st)->st_xtim.st__tim.tv_nsec) |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
51 #endif |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
52 |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
53 /* Return the nanosecond component of *ST's access time. */ |
17023
fc49ecfa5827
stat-time: use extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents:
16242
diff
changeset
|
54 _GL_STAT_TIME_INLINE long int |
6237
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
55 get_stat_atime_ns (struct stat const *st) |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
56 { |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
57 # if defined STAT_TIMESPEC |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
58 return STAT_TIMESPEC (st, st_atim).tv_nsec; |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
59 # elif defined STAT_TIMESPEC_NS |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
60 return STAT_TIMESPEC_NS (st, st_atim); |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
61 # else |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
62 return 0; |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
63 # endif |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
64 } |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
65 |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
66 /* Return the nanosecond component of *ST's status change time. */ |
17023
fc49ecfa5827
stat-time: use extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents:
16242
diff
changeset
|
67 _GL_STAT_TIME_INLINE long int |
6237
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
68 get_stat_ctime_ns (struct stat const *st) |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
69 { |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
70 # if defined STAT_TIMESPEC |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
71 return STAT_TIMESPEC (st, st_ctim).tv_nsec; |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
72 # elif defined STAT_TIMESPEC_NS |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
73 return STAT_TIMESPEC_NS (st, st_ctim); |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
74 # else |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
75 return 0; |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
76 # endif |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
77 } |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
78 |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
79 /* Return the nanosecond component of *ST's data modification time. */ |
17023
fc49ecfa5827
stat-time: use extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents:
16242
diff
changeset
|
80 _GL_STAT_TIME_INLINE long int |
6237
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
81 get_stat_mtime_ns (struct stat const *st) |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
82 { |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
83 # if defined STAT_TIMESPEC |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
84 return STAT_TIMESPEC (st, st_mtim).tv_nsec; |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
85 # elif defined STAT_TIMESPEC_NS |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
86 return STAT_TIMESPEC_NS (st, st_mtim); |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
87 # else |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
88 return 0; |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
89 # endif |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
90 } |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
91 |
8565
c49cf515502f
2007-03-27 Bruno Haible <bruno@clisp.org>
Bruno Haible <bruno@clisp.org>
parents:
8223
diff
changeset
|
92 /* Return the nanosecond component of *ST's birth time. */ |
17023
fc49ecfa5827
stat-time: use extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents:
16242
diff
changeset
|
93 _GL_STAT_TIME_INLINE long int |
8565
c49cf515502f
2007-03-27 Bruno Haible <bruno@clisp.org>
Bruno Haible <bruno@clisp.org>
parents:
8223
diff
changeset
|
94 get_stat_birthtime_ns (struct stat const *st) |
c49cf515502f
2007-03-27 Bruno Haible <bruno@clisp.org>
Bruno Haible <bruno@clisp.org>
parents:
8223
diff
changeset
|
95 { |
8567
f7fc3652bfc5
* lib/stat-time.h (USE_BIRTHTIME): Remove.
Paul Eggert <eggert@cs.ucla.edu>
parents:
8565
diff
changeset
|
96 # if defined HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC |
8565
c49cf515502f
2007-03-27 Bruno Haible <bruno@clisp.org>
Bruno Haible <bruno@clisp.org>
parents:
8223
diff
changeset
|
97 return STAT_TIMESPEC (st, st_birthtim).tv_nsec; |
8567
f7fc3652bfc5
* lib/stat-time.h (USE_BIRTHTIME): Remove.
Paul Eggert <eggert@cs.ucla.edu>
parents:
8565
diff
changeset
|
98 # elif defined HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC |
8565
c49cf515502f
2007-03-27 Bruno Haible <bruno@clisp.org>
Bruno Haible <bruno@clisp.org>
parents:
8223
diff
changeset
|
99 return STAT_TIMESPEC_NS (st, st_birthtim); |
8567
f7fc3652bfc5
* lib/stat-time.h (USE_BIRTHTIME): Remove.
Paul Eggert <eggert@cs.ucla.edu>
parents:
8565
diff
changeset
|
100 # else |
9679
381eff2df16b
Avoid two "parameter unused" warnings.
Jim Meyering <meyering@redhat.com>
parents:
9309
diff
changeset
|
101 /* Avoid a "parameter unused" warning. */ |
381eff2df16b
Avoid two "parameter unused" warnings.
Jim Meyering <meyering@redhat.com>
parents:
9309
diff
changeset
|
102 (void) st; |
8565
c49cf515502f
2007-03-27 Bruno Haible <bruno@clisp.org>
Bruno Haible <bruno@clisp.org>
parents:
8223
diff
changeset
|
103 return 0; |
8567
f7fc3652bfc5
* lib/stat-time.h (USE_BIRTHTIME): Remove.
Paul Eggert <eggert@cs.ucla.edu>
parents:
8565
diff
changeset
|
104 # endif |
8565
c49cf515502f
2007-03-27 Bruno Haible <bruno@clisp.org>
Bruno Haible <bruno@clisp.org>
parents:
8223
diff
changeset
|
105 } |
c49cf515502f
2007-03-27 Bruno Haible <bruno@clisp.org>
Bruno Haible <bruno@clisp.org>
parents:
8223
diff
changeset
|
106 |
6237
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
107 /* Return *ST's access time. */ |
17023
fc49ecfa5827
stat-time: use extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents:
16242
diff
changeset
|
108 _GL_STAT_TIME_INLINE struct timespec |
6237
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
109 get_stat_atime (struct stat const *st) |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
110 { |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
111 #ifdef STAT_TIMESPEC |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
112 return STAT_TIMESPEC (st, st_atim); |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
113 #else |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
114 struct timespec t; |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
115 t.tv_sec = st->st_atime; |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
116 t.tv_nsec = get_stat_atime_ns (st); |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
117 return t; |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
118 #endif |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
119 } |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
120 |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
121 /* Return *ST's status change time. */ |
17023
fc49ecfa5827
stat-time: use extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents:
16242
diff
changeset
|
122 _GL_STAT_TIME_INLINE struct timespec |
6237
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
123 get_stat_ctime (struct stat const *st) |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
124 { |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
125 #ifdef STAT_TIMESPEC |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
126 return STAT_TIMESPEC (st, st_ctim); |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
127 #else |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
128 struct timespec t; |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
129 t.tv_sec = st->st_ctime; |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
130 t.tv_nsec = get_stat_ctime_ns (st); |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
131 return t; |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
132 #endif |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
133 } |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
134 |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
135 /* Return *ST's data modification time. */ |
17023
fc49ecfa5827
stat-time: use extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents:
16242
diff
changeset
|
136 _GL_STAT_TIME_INLINE struct timespec |
6237
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
137 get_stat_mtime (struct stat const *st) |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
138 { |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
139 #ifdef STAT_TIMESPEC |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
140 return STAT_TIMESPEC (st, st_mtim); |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
141 #else |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
142 struct timespec t; |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
143 t.tv_sec = st->st_mtime; |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
144 t.tv_nsec = get_stat_mtime_ns (st); |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
145 return t; |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
146 #endif |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
147 } |
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
148 |
8567
f7fc3652bfc5
* lib/stat-time.h (USE_BIRTHTIME): Remove.
Paul Eggert <eggert@cs.ucla.edu>
parents:
8565
diff
changeset
|
149 /* Return *ST's birth time, if available; otherwise return a value |
14890
b3af6c2a46e4
stat-time: get_stat_birthtime failure is better-defined
Paul Eggert <eggert@cs.ucla.edu>
parents:
14573
diff
changeset
|
150 with tv_sec and tv_nsec both equal to -1. */ |
17023
fc49ecfa5827
stat-time: use extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents:
16242
diff
changeset
|
151 _GL_STAT_TIME_INLINE struct timespec |
8567
f7fc3652bfc5
* lib/stat-time.h (USE_BIRTHTIME): Remove.
Paul Eggert <eggert@cs.ucla.edu>
parents:
8565
diff
changeset
|
152 get_stat_birthtime (struct stat const *st) |
8565
c49cf515502f
2007-03-27 Bruno Haible <bruno@clisp.org>
Bruno Haible <bruno@clisp.org>
parents:
8223
diff
changeset
|
153 { |
c49cf515502f
2007-03-27 Bruno Haible <bruno@clisp.org>
Bruno Haible <bruno@clisp.org>
parents:
8223
diff
changeset
|
154 struct timespec t; |
8567
f7fc3652bfc5
* lib/stat-time.h (USE_BIRTHTIME): Remove.
Paul Eggert <eggert@cs.ucla.edu>
parents:
8565
diff
changeset
|
155 |
8621
71d64e4302fa
* lib/stat-time.h: (get_stat_birthtime): Check for zero-valued
Paul Eggert <eggert@cs.ucla.edu>
parents:
8568
diff
changeset
|
156 #if (defined HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC \ |
71d64e4302fa
* lib/stat-time.h: (get_stat_birthtime): Check for zero-valued
Paul Eggert <eggert@cs.ucla.edu>
parents:
8568
diff
changeset
|
157 || defined HAVE_STRUCT_STAT_ST_BIRTHTIM_TV_NSEC) |
8567
f7fc3652bfc5
* lib/stat-time.h (USE_BIRTHTIME): Remove.
Paul Eggert <eggert@cs.ucla.edu>
parents:
8565
diff
changeset
|
158 t = STAT_TIMESPEC (st, st_birthtim); |
f7fc3652bfc5
* lib/stat-time.h (USE_BIRTHTIME): Remove.
Paul Eggert <eggert@cs.ucla.edu>
parents:
8565
diff
changeset
|
159 #elif defined HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC |
f7fc3652bfc5
* lib/stat-time.h (USE_BIRTHTIME): Remove.
Paul Eggert <eggert@cs.ucla.edu>
parents:
8565
diff
changeset
|
160 t.tv_sec = st->st_birthtime; |
f7fc3652bfc5
* lib/stat-time.h (USE_BIRTHTIME): Remove.
Paul Eggert <eggert@cs.ucla.edu>
parents:
8565
diff
changeset
|
161 t.tv_nsec = st->st_birthtimensec; |
f7fc3652bfc5
* lib/stat-time.h (USE_BIRTHTIME): Remove.
Paul Eggert <eggert@cs.ucla.edu>
parents:
8565
diff
changeset
|
162 #elif (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ |
16242
59c686e5b2df
Talk about "native Windows API", not "Woe32".
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
163 /* Native Windows platforms (but not Cygwin) put the "file creation |
8567
f7fc3652bfc5
* lib/stat-time.h (USE_BIRTHTIME): Remove.
Paul Eggert <eggert@cs.ucla.edu>
parents:
8565
diff
changeset
|
164 time" in st_ctime (!). See |
f7fc3652bfc5
* lib/stat-time.h (USE_BIRTHTIME): Remove.
Paul Eggert <eggert@cs.ucla.edu>
parents:
8565
diff
changeset
|
165 <http://msdn2.microsoft.com/de-de/library/14h5k7ff(VS.80).aspx>. */ |
f7fc3652bfc5
* lib/stat-time.h (USE_BIRTHTIME): Remove.
Paul Eggert <eggert@cs.ucla.edu>
parents:
8565
diff
changeset
|
166 t.tv_sec = st->st_ctime; |
f7fc3652bfc5
* lib/stat-time.h (USE_BIRTHTIME): Remove.
Paul Eggert <eggert@cs.ucla.edu>
parents:
8565
diff
changeset
|
167 t.tv_nsec = 0; |
8565
c49cf515502f
2007-03-27 Bruno Haible <bruno@clisp.org>
Bruno Haible <bruno@clisp.org>
parents:
8223
diff
changeset
|
168 #else |
14890
b3af6c2a46e4
stat-time: get_stat_birthtime failure is better-defined
Paul Eggert <eggert@cs.ucla.edu>
parents:
14573
diff
changeset
|
169 /* Birth time is not supported. */ |
8567
f7fc3652bfc5
* lib/stat-time.h (USE_BIRTHTIME): Remove.
Paul Eggert <eggert@cs.ucla.edu>
parents:
8565
diff
changeset
|
170 t.tv_sec = -1; |
f7fc3652bfc5
* lib/stat-time.h (USE_BIRTHTIME): Remove.
Paul Eggert <eggert@cs.ucla.edu>
parents:
8565
diff
changeset
|
171 t.tv_nsec = -1; |
9679
381eff2df16b
Avoid two "parameter unused" warnings.
Jim Meyering <meyering@redhat.com>
parents:
9309
diff
changeset
|
172 /* Avoid a "parameter unused" warning. */ |
381eff2df16b
Avoid two "parameter unused" warnings.
Jim Meyering <meyering@redhat.com>
parents:
9309
diff
changeset
|
173 (void) st; |
6237
d81a8251a9b0
* MODULES.html.sh (File system functions): Add stat-time.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
174 #endif |
8567
f7fc3652bfc5
* lib/stat-time.h (USE_BIRTHTIME): Remove.
Paul Eggert <eggert@cs.ucla.edu>
parents:
8565
diff
changeset
|
175 |
8621
71d64e4302fa
* lib/stat-time.h: (get_stat_birthtime): Check for zero-valued
Paul Eggert <eggert@cs.ucla.edu>
parents:
8568
diff
changeset
|
176 #if (defined HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC \ |
71d64e4302fa
* lib/stat-time.h: (get_stat_birthtime): Check for zero-valued
Paul Eggert <eggert@cs.ucla.edu>
parents:
8568
diff
changeset
|
177 || defined HAVE_STRUCT_STAT_ST_BIRTHTIM_TV_NSEC \ |
71d64e4302fa
* lib/stat-time.h: (get_stat_birthtime): Check for zero-valued
Paul Eggert <eggert@cs.ucla.edu>
parents:
8568
diff
changeset
|
178 || defined HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC) |
71d64e4302fa
* lib/stat-time.h: (get_stat_birthtime): Check for zero-valued
Paul Eggert <eggert@cs.ucla.edu>
parents:
8568
diff
changeset
|
179 /* FreeBSD and NetBSD sometimes signal the absence of knowledge by |
71d64e4302fa
* lib/stat-time.h: (get_stat_birthtime): Check for zero-valued
Paul Eggert <eggert@cs.ucla.edu>
parents:
8568
diff
changeset
|
180 using zero. Attempt to work around this problem. Alas, this can |
71d64e4302fa
* lib/stat-time.h: (get_stat_birthtime): Check for zero-valued
Paul Eggert <eggert@cs.ucla.edu>
parents:
8568
diff
changeset
|
181 report failure even for valid time stamps. Also, NetBSD |
71d64e4302fa
* lib/stat-time.h: (get_stat_birthtime): Check for zero-valued
Paul Eggert <eggert@cs.ucla.edu>
parents:
8568
diff
changeset
|
182 sometimes returns junk in the birth time fields; work around this |
14890
b3af6c2a46e4
stat-time: get_stat_birthtime failure is better-defined
Paul Eggert <eggert@cs.ucla.edu>
parents:
14573
diff
changeset
|
183 bug if it is detected. */ |
b3af6c2a46e4
stat-time: get_stat_birthtime failure is better-defined
Paul Eggert <eggert@cs.ucla.edu>
parents:
14573
diff
changeset
|
184 if (! (t.tv_sec && 0 <= t.tv_nsec && t.tv_nsec < 1000000000)) |
b3af6c2a46e4
stat-time: get_stat_birthtime failure is better-defined
Paul Eggert <eggert@cs.ucla.edu>
parents:
14573
diff
changeset
|
185 { |
b3af6c2a46e4
stat-time: get_stat_birthtime failure is better-defined
Paul Eggert <eggert@cs.ucla.edu>
parents:
14573
diff
changeset
|
186 t.tv_sec = -1; |
b3af6c2a46e4
stat-time: get_stat_birthtime failure is better-defined
Paul Eggert <eggert@cs.ucla.edu>
parents:
14573
diff
changeset
|
187 t.tv_nsec = -1; |
b3af6c2a46e4
stat-time: get_stat_birthtime failure is better-defined
Paul Eggert <eggert@cs.ucla.edu>
parents:
14573
diff
changeset
|
188 } |
8621
71d64e4302fa
* lib/stat-time.h: (get_stat_birthtime): Check for zero-valued
Paul Eggert <eggert@cs.ucla.edu>
parents:
8568
diff
changeset
|
189 #endif |
71d64e4302fa
* lib/stat-time.h: (get_stat_birthtime): Check for zero-valued
Paul Eggert <eggert@cs.ucla.edu>
parents:
8568
diff
changeset
|
190 |
8567
f7fc3652bfc5
* lib/stat-time.h (USE_BIRTHTIME): Remove.
Paul Eggert <eggert@cs.ucla.edu>
parents:
8565
diff
changeset
|
191 return t; |
8565
c49cf515502f
2007-03-27 Bruno Haible <bruno@clisp.org>
Bruno Haible <bruno@clisp.org>
parents:
8223
diff
changeset
|
192 } |
c49cf515502f
2007-03-27 Bruno Haible <bruno@clisp.org>
Bruno Haible <bruno@clisp.org>
parents:
8223
diff
changeset
|
193 |
17023
fc49ecfa5827
stat-time: use extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents:
16242
diff
changeset
|
194 _GL_INLINE_HEADER_END |
fc49ecfa5827
stat-time: use extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents:
16242
diff
changeset
|
195 |
8565
c49cf515502f
2007-03-27 Bruno Haible <bruno@clisp.org>
Bruno Haible <bruno@clisp.org>
parents:
8223
diff
changeset
|
196 #endif |