ftp.nice.ch/pub/next/science/physics/gck.2.01.s.tar.gz#/gckc.2.0.1/gck_fileage.c

This is gck_fileage.c in view mode; [Download] [Up]

/* ******************************************************************** */
/* *                           GCK                                    * */
/* *               A Circuit Simulation Program                       * */
/* *                    by Tanju Cataltepe                            * */
/* *                    (c) Copyright 1989                            * */
/* ******************************************************************** */
/* (c) Copyright 1989, Tanju Cataltepe */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>			
#include <ctype.h>
#include <time.h>

#ifdef Macintosh
#include <console.h> 
#include <Files.h>
#else
#include <sys/types.h>
#include <sys/stat.h>
#endif

#include <math.h>
#include <float.h>
#include "gck.h"
#include "gck_vars.h"
#include "gck_protos.h"
#include "gck_errors.h"

#ifdef Macintosh
long FileAge(the_file)
#else
time_t FileAge(the_file)
#endif
char *the_file;
{

#ifdef Macintosh
  /* Macintosh Toolbox Call, Inside Macintosh Volume IV */
  OSErr				g;
  ParamBlockRec		Block;
  ParmBlkPtr		B;
  Str255			filename;
  FILE 				*f;
  aWord				tmp;
  
  strcpy(tmp,the_file);

  /* I think CtoPstr puts a Pascal string in place of the C string -- corrupts data */
  /* Fix by creating an image (tmp) */
  
  strcpy((char *)filename,(char *)CtoPstr(tmp));

  B = &Block;
  B->ioParam.ioCompletion = NULL;
  B->ioParam.ioVRefNum = 0;
  B->ioParam.ioNamePtr = (StringPtr) &filename;
  B->fileParam.ioFVersNum = 0;
  B->fileParam.ioFDirIndex = 0;

  f = fopen(the_file,"rb");
  if (f == NULL) {
    up_to_date = FALSE;
    return((time_t) 0);
    }
  else
    fclose(f);

  if (g = PBGetFInfo(B,(Boolean) FALSE) != 0) {
    up_to_date = FALSE;
    return((long) 0);
    }

  return(B->fileParam.ioFlMdDat);
    
#else
  /* Unix version */
  struct stat stbuf;
  FILE *f;

  f = fopen(the_file,"rb");
  if (f == NULL) {
    up_to_date = FALSE;
    return((time_t) 0);
    }
  else
    fclose(f);
    
  stat(the_file, &stbuf);
  return(stbuf.st_mtime);

#endif
}

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.