annotate kpathsea/file-p.c @ 1268:76a0c05089d4

[project @ 1995-04-20 19:15:51 by jwe] Initial revision
author jwe
date Thu, 20 Apr 1995 19:15:51 +0000
parents
children 611d403c7f3d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1268
76a0c05089d4 [project @ 1995-04-20 19:15:51 by jwe]
jwe
parents:
diff changeset
1 /* file-p.c: file predicates.
76a0c05089d4 [project @ 1995-04-20 19:15:51 by jwe]
jwe
parents:
diff changeset
2
76a0c05089d4 [project @ 1995-04-20 19:15:51 by jwe]
jwe
parents:
diff changeset
3 Copyright (C) 1992, 93, 94 Free Software Foundation, Inc.
76a0c05089d4 [project @ 1995-04-20 19:15:51 by jwe]
jwe
parents:
diff changeset
4
76a0c05089d4 [project @ 1995-04-20 19:15:51 by jwe]
jwe
parents:
diff changeset
5 This program is free software; you can redistribute it and/or modify
76a0c05089d4 [project @ 1995-04-20 19:15:51 by jwe]
jwe
parents:
diff changeset
6 it under the terms of the GNU General Public License as published by
76a0c05089d4 [project @ 1995-04-20 19:15:51 by jwe]
jwe
parents:
diff changeset
7 the Free Software Foundation; either version 2, or (at your option)
76a0c05089d4 [project @ 1995-04-20 19:15:51 by jwe]
jwe
parents:
diff changeset
8 any later version.
76a0c05089d4 [project @ 1995-04-20 19:15:51 by jwe]
jwe
parents:
diff changeset
9
76a0c05089d4 [project @ 1995-04-20 19:15:51 by jwe]
jwe
parents:
diff changeset
10 This program is distributed in the hope that it will be useful,
76a0c05089d4 [project @ 1995-04-20 19:15:51 by jwe]
jwe
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
76a0c05089d4 [project @ 1995-04-20 19:15:51 by jwe]
jwe
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
76a0c05089d4 [project @ 1995-04-20 19:15:51 by jwe]
jwe
parents:
diff changeset
13 GNU General Public License for more details.
76a0c05089d4 [project @ 1995-04-20 19:15:51 by jwe]
jwe
parents:
diff changeset
14
76a0c05089d4 [project @ 1995-04-20 19:15:51 by jwe]
jwe
parents:
diff changeset
15 You should have received a copy of the GNU General Public License
76a0c05089d4 [project @ 1995-04-20 19:15:51 by jwe]
jwe
parents:
diff changeset
16 along with this program; if not, write to the Free Software
76a0c05089d4 [project @ 1995-04-20 19:15:51 by jwe]
jwe
parents:
diff changeset
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
76a0c05089d4 [project @ 1995-04-20 19:15:51 by jwe]
jwe
parents:
diff changeset
18
76a0c05089d4 [project @ 1995-04-20 19:15:51 by jwe]
jwe
parents:
diff changeset
19 #include <kpathsea/config.h>
76a0c05089d4 [project @ 1995-04-20 19:15:51 by jwe]
jwe
parents:
diff changeset
20
76a0c05089d4 [project @ 1995-04-20 19:15:51 by jwe]
jwe
parents:
diff changeset
21 #include <kpathsea/xstat.h>
76a0c05089d4 [project @ 1995-04-20 19:15:51 by jwe]
jwe
parents:
diff changeset
22
76a0c05089d4 [project @ 1995-04-20 19:15:51 by jwe]
jwe
parents:
diff changeset
23
76a0c05089d4 [project @ 1995-04-20 19:15:51 by jwe]
jwe
parents:
diff changeset
24 /* Test whether FILENAME1 and FILENAME2 are actually the same file. If
76a0c05089d4 [project @ 1995-04-20 19:15:51 by jwe]
jwe
parents:
diff changeset
25 stat fails on either of the names, we return false, without error. */
76a0c05089d4 [project @ 1995-04-20 19:15:51 by jwe]
jwe
parents:
diff changeset
26
76a0c05089d4 [project @ 1995-04-20 19:15:51 by jwe]
jwe
parents:
diff changeset
27 boolean
76a0c05089d4 [project @ 1995-04-20 19:15:51 by jwe]
jwe
parents:
diff changeset
28 same_file_p P2C(const_string, filename1, const_string, filename2)
76a0c05089d4 [project @ 1995-04-20 19:15:51 by jwe]
jwe
parents:
diff changeset
29 {
76a0c05089d4 [project @ 1995-04-20 19:15:51 by jwe]
jwe
parents:
diff changeset
30 struct stat sb1, sb2;
76a0c05089d4 [project @ 1995-04-20 19:15:51 by jwe]
jwe
parents:
diff changeset
31 /* These are put in variables only so the results can be inspected
76a0c05089d4 [project @ 1995-04-20 19:15:51 by jwe]
jwe
parents:
diff changeset
32 under gdb. */
76a0c05089d4 [project @ 1995-04-20 19:15:51 by jwe]
jwe
parents:
diff changeset
33 int r1 = stat (filename1, &sb1);
76a0c05089d4 [project @ 1995-04-20 19:15:51 by jwe]
jwe
parents:
diff changeset
34 int r2 = stat (filename2, &sb2);
76a0c05089d4 [project @ 1995-04-20 19:15:51 by jwe]
jwe
parents:
diff changeset
35
76a0c05089d4 [project @ 1995-04-20 19:15:51 by jwe]
jwe
parents:
diff changeset
36 return r1 == 0 && r2 == 0 ? SAME_FILE_P (sb1, sb2) : false;
76a0c05089d4 [project @ 1995-04-20 19:15:51 by jwe]
jwe
parents:
diff changeset
37 }