view lib/same-inode.h @ 38226:ad896936aac4

same-inode: port to MinGW Here st_ino is always 0, so change the definition of SAME_INODE so that 1 means the two files are the same, 0 with st_ino != 0 means they differ, and 0 with st_ino == 0 means we don’t know. Problem reported by Bruno Haible (Bug#25146). * doc/posix-headers/sys_stat.texi (sys/stat.h): Update. * lib/same-inode.h (SAME_INODE): Return 0 on MinGW.
author Paul Eggert <eggert@cs.ucla.edu>
date Fri, 09 Dec 2016 08:16:13 -0800
parents 005e281c3dfc
children 12df2165ec1c
line wrap: on
line source

/* Determine whether two stat buffers are known to refer to the same file.

   Copyright (C) 2006, 2009-2016 Free Software Foundation, Inc.

   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

#ifndef SAME_INODE_H
# define SAME_INODE_H 1

# ifdef __VMS
#  define SAME_INODE(a, b)             \
    ((a).st_ino[0] == (b).st_ino[0]    \
     && (a).st_ino[1] == (b).st_ino[1] \
     && (a).st_ino[2] == (b).st_ino[2] \
     && (a).st_dev == (b).st_dev)
# elif (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
/* On MinGW, struct stat lacks necessary info, so always return 0.
   Callers can use !a.st_ino to deduce that the information is unknown.  */
#  define SAME_INODE(a, b) 0
# else
#  define SAME_INODE(a, b)    \
    ((a).st_ino == (b).st_ino \
     && (a).st_dev == (b).st_dev)
# endif

#endif