home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 3 / PDCD_3.iso / tex / texsrc1 / Src / lib / c / file-p < prev    next >
Encoding:
Text File  |  1993-05-02  |  1.4 KB  |  47 lines

  1. /* file-p.c: file predicates.
  2.  
  3. Copyright (C) 1992 Free Software Foundation, Inc.
  4.  
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2, or (at your option)
  8. any later version.
  9.  
  10. This program 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
  13. GNU General Public License for more details.
  14.  
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software
  17. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  18.  
  19. #include "config.h"
  20.  
  21. #ifdef RISCOS
  22. #include "riscos_ex.h"
  23. #define same_file_p(file1, file2) riscos_samefile(file1, file2)
  24.  
  25. #else /* not RISC OS */
  26.  
  27. #include "xstat.h"
  28.  
  29. /* Test whether FILENAME1 and FILENAME2 are actually the same file.  If
  30.    stat fails on either of the names, we return false, without error.  */
  31.  
  32. boolean
  33. same_file_p P2C(string, filename1,  string, filename2)
  34. {
  35.     struct stat sb1, sb2;
  36.     /* These are put in variables only so the results can be inspected
  37.        under gdb.  */
  38.     int r1 = stat (filename1, &sb1);
  39.     int r2 = stat (filename2, &sb2);
  40.  
  41.     if (r1 == 0 && r2 == 0)
  42.       return sb1.st_ino == sb2.st_ino && sb2.st_dev == sb2.st_dev;
  43.     else
  44.       return false;
  45. }
  46. #endif /* not RISC OS */
  47.