EMAN2
portable_fileio.h
Go to the documentation of this file.
1/*
2 * Author: Liwei Peng, 08/27/2003 (sludtke@bcm.edu)
3 * Copyright (c) 2000-2006 Baylor College of Medicine
4 *
5 * This software is issued under a joint BSD/GNU license. You may use the
6 * source code in this file under either license. However, note that the
7 * complete EMAN2 and SPARX software packages have some GPL dependencies,
8 * so you are responsible for compliance with the licenses of these packages
9 * if you opt to use BSD licensing. The warranty disclaimer below holds
10 * in either instance.
11 *
12 * This complete copyright notice must be included in any revised version of the
13 * source code. Additional authorship citations may be added, but existing
14 * author citations must be preserved.
15 *
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 *
30 * */
31
32#ifndef __portable_fileio_h__
33#define __portable_fileio_h__
34
35#include <cstdio>
36#include <sys/types.h>
37
38
39inline int portable_fseek(FILE * fp, off_t offset, int whence)
40{
41#if defined(HAVE_FSEEKO)
42 return fseeko(fp, offset, whence);
43#elif defined(HAVE_FSEEK64)
44 return fseek64(fp, offset, whence);
45#elif defined(__BEOS__)
46 return _fseek(fp, offset, whence);
47#else
48 return fseek(fp, offset, whence);
49#endif
50}
51
52inline off_t portable_ftell(FILE * fp)
53{
54#if defined(HAVE_FTELLO)
55 return ftello(fp);
56#elif defined(HAVE_FTELL64)
57 return ftell64(fp);
58#else
59 return ftell(fp);
60#endif
61}
62
63
64
65#endif
off_t portable_ftell(FILE *fp)
int portable_fseek(FILE *fp, off_t offset, int whence)