#include "make.h"

long gtime( file )
char *file;
   {
   BPTR TestLock, Lock();
   struct FileInfoBlock *fi;
   long t;

   /* first see if we can open the file */
   if ( (TestLock = Lock( file, SHARED_LOCK )) == NULL )
      return(0);

   fi = (struct FileInfoBlock *)getmem(sizeof(struct FileInfoBlock));
   if (!fi) err("gtime: out of memory");

#if 0
   printf("Days : %08lx   Minutes : %08lx   Ticks : %08lx\n",
           fi->fib_Date.ds_Days,
                          fi->fib_Date.ds_Minute,
                                            fi->fib_Date.ds_Tick );
#endif

   t = (Examine( TestLock, fi ))
       ? ((fi->fib_Date.ds_Days * 1440 +
           fi->fib_Date.ds_Minute ) * 60 +
           fi->fib_Date.ds_Tick / TICKS_PER_SECOND )
       : 0;

   UnLock(TestLock);
   rlsmem(fi, sizeof(struct FileInfoBlock));

   return(t);
   }

long timenow()
  {
  struct DateStamp now;

  DateStamp( &now );

#if 0
   printf("Days : %08lx   Minutes : %08lx   Ticks : %08lx\n",
           now.ds_Days,   now.ds_Minute,    now.ds_Tick );
#endif

   return((now.ds_Days * 1440 +
           now.ds_Minute ) * 60 +
           now.ds_Tick / TICKS_PER_SECOND );
  }

int exist(file)
char *file;
{
   BPTR TestLock, Lock();

   /* first see if we can open the file */
   if ( (TestLock = Lock( file, SHARED_LOCK )) == NULL )
      return(0);

   UnLock( TestLock );
   return(1);
}
