#include <sys/stat.h>#include <string.h>#include "InputFile.hh"Include dependency graph for InputFile.cpp:

Go to the source code of this file.
Functions | |
| FILE * | OpenInputFile (UsageEnvironment &env, char const *fileName) |
| void | CloseInputFile (FILE *fid) |
| u_int64_t | GetFileSize (char const *fileName, FILE *fid) |
| int64_t | SeekFile64 (FILE *fid, int64_t offset, int whence) |
| int64_t | TellFile64 (FILE *fid) |
| void CloseInputFile | ( | FILE * | fid | ) |
Definition at line 51 of file InputFile.cpp.
References NULL.
Referenced by MPEG2TransportStreamIndexFile::closeFid(), ADTSAudioFileSource::createNew(), AMRAudioFileSource::createNew(), ADTSAudioFileSource::~ADTSAudioFileSource(), AMRAudioFileSource::~AMRAudioFileSource(), and WAVAudioFileSource::~WAVAudioFileSource().
00051 { 00052 // Don't close 'stdin', in case we want to use it again later. 00053 if (fid != NULL && fid != stdin) fclose(fid); 00054 }
| u_int64_t GetFileSize | ( | char const * | fileName, | |
| FILE * | fid | |||
| ) |
Definition at line 56 of file InputFile.cpp.
References NULL, SeekFile64(), and TellFile64().
Referenced by ByteStreamFileSource::createNew(), MP3FileSource::createNew(), WAVAudioFileSource::createNew(), and MPEG2TransportStreamIndexFile::MPEG2TransportStreamIndexFile().
00056 { 00057 u_int64_t fileSize = 0; // by default 00058 00059 if (fid != stdin) { 00060 #if !defined(_WIN32_WCE) 00061 if (fileName == NULL) { 00062 #endif 00063 if (fid != NULL && SeekFile64(fid, 0, SEEK_END) >= 0) { 00064 fileSize = (u_int64_t)TellFile64(fid); 00065 if (fileSize == (u_int64_t)-1) fileSize = 0; // TellFile64() failed 00066 SeekFile64(fid, 0, SEEK_SET); 00067 } 00068 #if !defined(_WIN32_WCE) 00069 } else { 00070 struct stat sb; 00071 if (stat(fileName, &sb) == 0) { 00072 fileSize = sb.st_size; 00073 } 00074 } 00075 #endif 00076 } 00077 00078 return fileSize; 00079 }
| FILE* OpenInputFile | ( | UsageEnvironment & | env, | |
| char const * | fileName | |||
| ) |
Definition at line 32 of file InputFile.cpp.
References env, NULL, and UsageEnvironment::setResultMsg().
Referenced by ADTSAudioFileSource::createNew(), AMRAudioFileSource::createNew(), ByteStreamFileSource::createNew(), MP3FileSource::createNew(), WAVAudioFileSource::createNew(), and MPEG2TransportStreamIndexFile::openFid().
00032 { 00033 FILE* fid; 00034 00035 // Check for a special case file name: "stdin" 00036 if (strcmp(fileName, "stdin") == 0) { 00037 fid = stdin; 00038 #if defined(__WIN32__) || defined(_WIN32) 00039 _setmode(_fileno(stdin), _O_BINARY); // convert to binary mode 00040 #endif 00041 } else { 00042 fid = fopen(fileName, "rb"); 00043 if (fid == NULL) { 00044 env.setResultMsg("unable to open file \"",fileName, "\""); 00045 } 00046 } 00047 00048 return fid; 00049 }
| int64_t SeekFile64 | ( | FILE * | fid, | |
| int64_t | offset, | |||
| int | whence | |||
| ) |
Definition at line 81 of file InputFile.cpp.
Referenced by GetFileSize(), ByteStreamFileSource::seekToByteAbsolute(), ByteStreamFileSource::seekToByteRelative(), and MPEG2TransportStreamIndexFile::seekToIndexRecord().
00081 { 00082 clearerr(fid); 00083 fflush(fid); 00084 #if (defined(__WIN32__) || defined(_WIN32)) && !defined(_WIN32_WCE) 00085 return _lseeki64(_fileno(fid), offset, whence) == (int64_t)-1 ? -1 : 0; 00086 #else 00087 #if defined(_WIN32_WCE) 00088 return fseek(fid, (long)(offset), whence); 00089 #else 00090 return fseeko(fid, (off_t)(offset), whence); 00091 #endif 00092 #endif 00093 }
| int64_t TellFile64 | ( | FILE * | fid | ) |
Definition at line 95 of file InputFile.cpp.
Referenced by GetFileSize().
00095 { 00096 clearerr(fid); 00097 fflush(fid); 00098 #if (defined(__WIN32__) || defined(_WIN32)) && !defined(_WIN32_WCE) 00099 return _telli64(_fileno(fid)); 00100 #else 00101 #if defined(_WIN32_WCE) 00102 return ftell(fid); 00103 #else 00104 return ftello(fid); 00105 #endif 00106 #endif 00107 }
1.5.2