3 * Copyright (c) 2002 Frodo
4 * Portions Copyright (c) by the authors of ffmpeg and xvid
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 // IFile.h: interface for the IFile class.
22 //////////////////////////////////////////////////////////////////////
24 #if !defined(AFX_IFILE_H__7EE73AC7_36BC_4822_93FF_44F3B0C766F6__INCLUDED_)
25 #define AFX_IFILE_H__7EE73AC7_36BC_4822_93FF_44F3B0C766F6__INCLUDED_
29 #endif // _MSC_VER > 1000
32 #include "PlatformDefs.h" // for __stat64
44 struct SNativeIoControl
52 uint64_t forward; /**< number of bytes cached forward of current position */
53 unsigned maxrate; /**< maximum number of bytes per second cache is allowed to fill */
54 unsigned currate; /**< average read rate from source file since last position change */
55 bool full; /**< is the cache full */
59 IOCTRL_NATIVE = 1, /**< SNativeIoControl structure, containing what should be passed to native ioctrl */
60 IOCTRL_SEEK_POSSIBLE = 2, /**< return 0 if known not to work, 1 if it should work */
61 IOCTRL_CACHE_STATUS = 3, /**< SCacheStatus structure */
62 IOCTRL_CACHE_SETRATE = 4, /**< unsigned int with with speed limit for caching in bytes per second */
71 virtual bool Open(const CURL& url) = 0;
72 virtual bool OpenForWrite(const CURL& url, bool bOverWrite = false) { return false; };
73 virtual bool Exists(const CURL& url) = 0;
74 virtual int Stat(const CURL& url, struct __stat64* buffer) = 0;
75 virtual int Stat(struct __stat64* buffer);
76 virtual unsigned int Read(void* lpBuf, int64_t uiBufSize) = 0;
77 virtual int Write(const void* lpBuf, int64_t uiBufSize) { return -1;};
78 virtual bool ReadString(char *szLine, int iLineLength);
79 virtual int64_t Seek(int64_t iFilePosition, int iWhence = SEEK_SET) = 0;
80 virtual void Close() = 0;
81 virtual int64_t GetPosition() = 0;
82 virtual int64_t GetLength() = 0;
83 virtual void Flush() { }
85 /* Returns the minium size that can be read from input stream. *
86 * For example cdrom access where access could be sector based. *
87 * This will cause file system to buffer read requests, to *
88 * to meet the requirement of CFile. *
89 * It can also be used to indicate a file system is non buffered *
90 * but accepts any read size, have it return the value 1 */
91 virtual int GetChunkSize() {return 0;}
93 virtual bool SkipNext(){return false;}
95 virtual bool Delete(const CURL& url) { return false; }
96 virtual bool Rename(const CURL& url, const CURL& urlnew) { return false; }
97 virtual bool SetHidden(const CURL& url, bool hidden) { return false; }
99 virtual int IoControl(EIoControl request, void* param) { return -1; }
101 virtual CStdString GetContent() { return "application/octet-stream"; }
104 class CRedirectException
107 IFile *m_pNewFileImp;
110 CRedirectException() : m_pNewFileImp(NULL), m_pNewUrl(NULL) { }
112 CRedirectException(IFile *pNewFileImp, CURL *pNewUrl=NULL)
113 : m_pNewFileImp(pNewFileImp)
120 #endif // !defined(AFX_IFILE_H__7EE73AC7_36BC_4822_93FF_44F3B0C766F6__INCLUDED_)