home *** CD-ROM | disk | FTP | other *** search
/ Super Net 1 / SUPERNET_1.iso / PC / OTROS / EXTRAS / UUCODE / UUPC / TEST / UPC12ES1.ZIP / LIB / stater.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-10-28  |  3.7 KB  |  95 lines

  1. /*--------------------------------------------------------------------*/
  2. /*    s t a t e r . c                                                 */
  3. /*                                                                    */
  4. /*    File time and size routines                                     */
  5. /*--------------------------------------------------------------------*/
  6.  
  7. /*--------------------------------------------------------------------*/
  8. /*    Changes Copyright (c) 1989-1993 by Kendra Electronic            */
  9. /*    Wonderworks.                                                    */
  10. /*                                                                    */
  11. /*    All rights reserved except those explicitly granted by the      */
  12. /*    UUPC/extended license agreement.                                */
  13. /*--------------------------------------------------------------------*/
  14.  
  15. /*--------------------------------------------------------------------*/
  16. /*                          RCS Information                           */
  17. /*--------------------------------------------------------------------*/
  18.  
  19. /*
  20.  *    $Id: stater.c 1.4 1993/10/28 12:19:01 ahd Exp $
  21.  *
  22.  *    Revision history:
  23.  *    $Log: stater.c $
  24.  *     Revision 1.4  1993/10/28  12:19:01  ahd
  25.  *     Cosmetic time formatting twiddles and clean ups
  26.  *
  27.  *     Revision 1.3  1993/10/09  15:47:51  rhg
  28.  *     ANSIify the source
  29.  *
  30.  *     Revision 1.3  1993/10/09  15:47:51  rhg
  31.  *     ANSIify the source
  32.  *
  33.  *     Revision 1.2  1993/07/20  21:45:37  ahd
  34.  *     Report last modified time, not created time, per Kae Uwe Rommel
  35.  *
  36.  */
  37.  
  38. /*--------------------------------------------------------------------*/
  39. /*                   Standard library include files                   */
  40. /*--------------------------------------------------------------------*/
  41.  
  42. #include <stdio.h>
  43. #include <time.h>
  44. #include <sys/types.h>
  45. #include <fcntl.h>
  46. #include <sys/stat.h>
  47.  
  48. /*--------------------------------------------------------------------*/
  49. /*                    UUPC/extended include files                     */
  50. /*--------------------------------------------------------------------*/
  51.  
  52. #include "lib.h"
  53.  
  54. /*--------------------------------------------------------------------*/
  55. /*                      Define current file name                      */
  56. /*--------------------------------------------------------------------*/
  57.  
  58. currentfile();
  59.  
  60. /*--------------------------------------------------------------------*/
  61. /*    s t a t e r                                                     */
  62. /*                                                                    */
  63. /*    Report date and size of a file                                  */
  64. /*--------------------------------------------------------------------*/
  65.  
  66. time_t stater(const char *file, long *size)
  67. {
  68.    struct stat statbuf;
  69.  
  70. /*--------------------------------------------------------------------*/
  71. /*   If the file doesn't exist, give a nasty message to the caller    */
  72. /*--------------------------------------------------------------------*/
  73.  
  74.    if(stat((char *) file, &statbuf) < 0 )
  75.    {
  76.       printmsg(0,"cannot stat %s",file);
  77.       printerr( file );
  78.       if ( size != NULL )
  79.          *size = 0;
  80.       return (time_t) -1L;    /* Flag file as missing          */
  81.    }
  82.  
  83. /*--------------------------------------------------------------------*/
  84. /*          We have the information; return it to the caller          */
  85. /*--------------------------------------------------------------------*/
  86.  
  87.    if ( size != NULL )
  88.       *size = statbuf.st_size;
  89.  
  90.    printmsg(5,"stater: \"%s\" is %ld bytes; updated %.24s",
  91.          file, *size, ctime( &statbuf.st_mtime));
  92.    return(statbuf.st_mtime);
  93.  
  94. } /* stater */
  95.