Edinburgh Speech Tools  2.1-release
EST_File.h
Go to the documentation of this file.
1 /************************************************************************/
2 /* */
3 /* Centre for Speech Technology Research */
4 /* University of Edinburgh, UK */
5 /* Copyright (c) 1996,1997 */
6 /* All Rights Reserved. */
7 /* */
8 /* Permission is hereby granted, free of charge, to use and distribute */
9 /* this software and its documentation without restriction, including */
10 /* without limitation the rights to use, copy, modify, merge, publish, */
11 /* distribute, sublicense, and/or sell copies of this work, and to */
12 /* permit persons to whom this work is furnished to do so, subject to */
13 /* the following conditions: */
14 /* 1. The code must retain the above copyright notice, this list of */
15 /* conditions and the following disclaimer. */
16 /* 2. Any modifications must be clearly marked as such. */
17 /* 3. Original authors' names are not deleted. */
18 /* 4. The authors' names are not used to endorse or promote products */
19 /* derived from this software without specific prior written */
20 /* permission. */
21 /* */
22 /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */
23 /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
24 /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
25 /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */
26 /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
27 /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
28 /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
29 /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
30 /* THIS SOFTWARE. */
31 /* */
32 /************************************************************************/
33 /* Author: Sergio Oller */
34 /* Date: March 2014 */
35 /************************************************************************/
36 /* */
37 /* Portable file I/O functions supporting large files */
38 /* */
39 /* In order to provide large file support, we need to use an 8 byte */
40 /* integer type at least. On POSIX systems this is usually done by */
41 /* using off_t type to store ftell function return values and by */
42 /* compiling with -D_FILE_OFFSET_BITS=64. */
43 /* */
44 /* On MSVS2012 we can use __int64, _fseeki64, _ftelli64 */
45 /* */
46 /* For now and until a safe, common, standard and portable solution is */
47 /* known, this file will be our portability layer among systems */
48 /* I just hope this file to become useless some day */
49 /************************************************************************/
50 
51 
52 #ifndef EST_File_H_
53 #define EST_File_H_
54 
55 #if defined(_WIN32) /* Win32 or Win64 */
56 
57 typedef __int64 EST_FilePos;
58 
59 inline EST_FilePos EST_ftell(FILE *fp) {
60  return _ftelli64(fp);
61 }
62 
63 inline int EST_fseek(FILE *fp, EST_FilePos offset, int whence) {
64  return _fseeki64(fp, offset, whence);
65 }
66 
67 #else
68 
69 typedef off_t EST_FilePos;
70 
71 inline EST_FilePos EST_ftell(FILE *fp) {
72  return ftell(fp);
73 }
74 
75 inline int EST_fseek(FILE *fp, EST_FilePos offset, int whence) {
76  return fseek(fp, offset, whence);
77 }
78 
79 #endif
80 #endif /* header guard */
EST_FilePos EST_ftell(FILE *fp)
Definition: EST_File.h:71
int EST_fseek(FILE *fp, EST_FilePos offset, int whence)
Definition: EST_File.h:75
LISP fp
Definition: kkcompile.cc:63
off_t EST_FilePos
Definition: EST_File.h:69