1
/*===========================================================================
2
Copyright (C) 1988-2009 European Southern Observatory (ESO)
4
This program is free software; you can redistribute it and/or
5
modify it under the terms of the GNU General Public License as
6
published by the Free Software Foundation; either version 2 of
7
the License, or (at your option) any later version.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public
15
License along with this program; if not, write to the Free
16
Software Foundation, Inc., 675 Massachusetts Ave, Cambridge,
19
Correspondence concerning ESO-MIDAS should be addressed as follows:
20
Internet e-mail: midas@eso.org
21
Postal address: European Southern Observatory
22
Data Management Division
23
Karl-Schwarzschild-Strasse 2
24
D 85748 Garching bei Muenchen
26
===========================================================================*/
28
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
32
.AUTHOR IPG-ESO Garching
33
.CATEGORY Host operating system interfaces. File management.
34
.ENVIRONMENT UNIX (BSD / SYSV)
36
Date of last modification of a file.
37
.VERSION 1.0 04-Oct-1988 F. Ochsenbein
40
-----------------------------------------------*/
42
#define DEBUG 0 /* Set to 1 for Debugging Option */
44
#include <osdefos.h> /* OS Midas definitions */
45
#include <errno.h> /* System error definitions */
46
#include <oserror.h> /* Midas error definitions */
47
#include <unistd.h> /* Midas error definitions */
48
#include <sys/types.h>
50
#include <proto_os.h> /* ANSI-C prototyping */
56
#define RETURN(x) FIN: return(oserror ? -1 : x)
57
#define FINISH goto FIN
59
static struct stat buf;
62
/*======================================================================*/
65
int osfop(char fmt, int length)
67
int osfop(fmt, length)
69
.PURPOSE Initializes the Format for the next Open / Create
71
.REMARKS Only for VMS (useless in Unix context)
72
------------------------------------------------------------*/
73
char fmt; /* IN : 'f' for Fixed, 'v' for Variable */
74
int length; /* IN : Length of longest record */
80
/*======================================================================*/
81
int osfunix(/*filename*/)
83
.PURPOSE Tells if a file is Unix--compatible
84
.RETURNS 1 (always valid)
85
.REMARKS Only for VMS compatibility
86
------------------------------------------------------------*/
87
/*char *filename;*/ /* IN : File to Check */
92
/*==========================================================================*/
93
long int osfdate(phname)
94
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
95
.PURPOSE Retrieve last modification date of a file.
96
.RETURNS The date in seconds
98
------------------------------------------------------------*/
99
char *phname; /* IN : physical filename */
103
if (access(phname,F_OK) != 0) { oserror = ENOENT; FINISH; }
104
/* Check for accessibility of file first */
106
if (stat(phname,&buf) != 0) { oserror = errno; FINISH; }
110
printf("Date of file %s = %d(oserror=%d)\n", phname, buf.st_mtime,oserror);
112
return(oserror ? -1L : buf.st_mtime);
115
/*==========================================================================*/
116
long int osfsize(phname)
117
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
118
.PURPOSE Get the size of a file.
119
.RETURNS Size of file in bytes (-1 if file does not exist).
121
------------------------------------------------------------*/
122
char *phname; /* IN : physical filename */
127
if (access(phname,F_OK) != 0) { oserror = ENOENT; FINISH; }
128
/* Check for accessibility of file first */
130
if (stat(phname,&buf) != 0) { oserror = errno; FINISH; }
133
return(oserror ? -1L : buf.st_size);