live
InputFile.hh
Go to the documentation of this file.
1 /**********
2 This library is free software; you can redistribute it and/or modify it under
3 the terms of the GNU Lesser General Public License as published by the
4 Free Software Foundation; either version 3 of the License, or (at your
5 option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
6 
7 This library is distributed in the hope that it will be useful, but WITHOUT
8 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
10 more details.
11 
12 You should have received a copy of the GNU Lesser General Public License
13 along with this library; if not, write to the Free Software Foundation, Inc.,
14 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15 **********/
16 // "liveMedia"
17 // Copyright (c) 1996-2021 Live Networks, Inc. All rights reserved.
18 // Common routines for opening/closing named input files
19 // C++ header
20 
21 #ifndef _INPUT_FILE_HH
22 #define _INPUT_FILE_HH
23 
24 #include <UsageEnvironment.hh>
25 #include <stdio.h>
26 
27 #if (defined(__WIN32__) || defined(_WIN32) || defined(_WIN32_WCE))
28 #ifndef _WIN32_WCE
29 // Include header files that might be needed by Windows (in code that uses this header file):
30 #include <io.h>
31 #include <fcntl.h>
32 #endif
33 
34 #define READ_FROM_FILES_SYNCHRONOUSLY 1
35  // Because Windows is a silly toy operating system that doesn't (reliably) treat
36  // open files as being readable sockets (which can be handled within the default
37  // "BasicTaskScheduler" event loop, using "select()"), we implement file reading
38  // in Windows using synchronous, rather than asynchronous, I/O. This can severely
39  // limit the scalability of servers using this code that run on Windows.
40  // If this is a problem for you, then either use a better operating system,
41  // or else write your own Windows-specific event loop ("TaskScheduler" subclass)
42  // that can handle readable data in Windows open files as an event.
43 #endif
44 
45 #ifndef _WIN32_WCE
46 #include <sys/stat.h>
47 #endif
48 
49 FILE* OpenInputFile(UsageEnvironment& env, char const* fileName);
50 
51 void CloseInputFile(FILE* fid);
52 
53 #undef GetFileSize // because some platforms already define this as a macro
54 u_int64_t GetFileSize(char const* fileName, FILE* fid);
55  // 0 means zero-length, unbounded, or unknown
56 
57 int64_t SeekFile64(FILE *fid, int64_t offset, int whence);
58  // A platform-independent routine for seeking within (possibly) large files
59 
60 int64_t TellFile64(FILE *fid);
61  // A platform-independent routine for reporting the position within
62  // (possibly) large files
63 
65  // Tests whether "fid" is seekable, by trying to seek within it.
66 
67 #endif
unsigned char Boolean
Definition: Boolean.hh:25
Boolean FileIsSeekable(FILE *fid)
u_int64_t GetFileSize(char const *fileName, FILE *fid)
FILE * OpenInputFile(UsageEnvironment &env, char const *fileName)
int64_t SeekFile64(FILE *fid, int64_t offset, int whence)
int64_t TellFile64(FILE *fid)
void CloseInputFile(FILE *fid)