GridLab
Grid Application Toolkit

A simple API for Grid Applications
GAT

Menu



Main Page   Alphabetical List   Compound List   File List   Compound Members   File Members  

file_lastwritetime_tests.c

Go to the documentation of this file.
00001 /** @file file_lastwritetime.c
00002  * Example of using the GAT to get the size of a file.
00003  * 
00004  * Uses the GAT to get the size of a file at a given URI is readable.
00005  * 
00006  * @date Mon Oct 6 2003
00007  * 
00008  * @version $Header: /export/cvs-gridlab/wp-1/Codes/GATEngine/C-reference/test/simple/file_lastwritetime_tests.c,v 1.9 2004/04/20 17:04:59 hartmutkaiser Exp $
00009  *
00010  *  Copyright (C) Hartmut Kaiser
00011  *  This file is part of the GAT Engine.
00012  *  Contributed by Hartmut Kaiser <hartmutkaiser [at] t-online [dot] de>.
00013  *
00014  *  Use, modification and distribution is subject to the Gridlab Software
00015  *  License. (See accompanying file GLlicense.txt or copy at
00016  *  http://www.gridlab.org/GLlicense.txt)
00017  */
00018 
00019 static const char *rcsid = "$Header: /export/cvs-gridlab/wp-1/Codes/GATEngine/C-reference/test/simple/file_lastwritetime_tests.c,v 1.9 2004/04/20 17:04:59 hartmutkaiser Exp $";
00020 
00021 
00022 /* System Header Files */
00023 
00024 #include <stdio.h>
00025 #include <stdlib.h>
00026 #include <time.h>
00027 
00028 
00029 /* GAT Header Files */
00030 
00031 #include <GAT.h>
00032 #include <GATTestUtils.h>
00033 
00034 
00035 /* External functions */
00036 
00037 int main (void)
00038 {
00039   GATResult   retcode       = GAT_SUCCESS;
00040   GATTime     lastwritetime = NULL;
00041   GATContext  context       = NULL;
00042   GATLocation target        = NULL;
00043   GATFile     file          = NULL;
00044   const char* src           = NULL;
00045 
00046   GAT_TEST_INIT  (-1);
00047   GAT_TEST_SUITE ("File")
00048 
00049   context = GATContext_Create();
00050   GAT_TEST(NULL != context);
00051   
00052   /* the following test makes sure, that there were no errors during the 
00053      creation of the GATContext object */
00054   GAT_TEST_TRACE(GATType_GATContext == GATContext_GetType(context), context);
00055 
00056   GAT_TEST_START ("File LastWriteTime Test")
00057 
00058   src = GATTest_GetTempFileName ("gat_src");
00059   GAT_TEST_TRACE (NULL != src, context);
00060 
00061   target = GATLocation_Create (src);
00062   GAT_TEST_TRACE (NULL != target, context);
00063 
00064   file = GATFile_Create (context, target, 0);
00065   GAT_TEST_TRACE (NULL != file, context);
00066   
00067   retcode = GATFile_LastWriteTime (file, &lastwritetime);
00068   GAT_TEST_TRACE (GAT_SUCCESS == retcode, context);
00069   GAT_TEST_TRACE (NULL != lastwritetime, context);
00070 
00071   // time_t loc_time = GATTime_GetTime  (lastwritetime);
00072   // struct tm *loc_time_tm = localtime (&loc_time);
00073 
00074   // printf ("The last write time of the file '%s' was %s.", src, 
00075   //         asctime (loc_time_tm));
00076 
00077   GATTime_Destroy     (&lastwritetime);
00078   GATFile_Destroy     (&file);
00079   GATLocation_Destroy (&target);
00080   GATContext_Destroy  (&context);
00081 
00082   GAT_TEST_STOP ();
00083   GAT_TEST_FINISH();
00084 
00085   return (retcode);
00086 }
00087 
00088 /* Local functions */