Merge pull request #4857 from t-nelson/Gotham_13.2_backports
[vuplus_xbmc] / xbmc / filesystem / IFile.h
1 /*
2  *      Copyright (c) 2002 Frodo
3  *      Portions Copyright (c) by the authors of ffmpeg and xvid
4  *      Copyright (C) 2002-2013 Team XBMC
5  *      http://xbmc.org
6  *
7  *  This Program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation; either version 2, or (at your option)
10  *  any later version.
11  *
12  *  This Program is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License
18  *  along with XBMC; see the file COPYING.  If not, see
19  *  <http://www.gnu.org/licenses/>.
20  *
21  */
22
23 // IFile.h: interface for the IFile class.
24 //
25 //////////////////////////////////////////////////////////////////////
26
27 #if !defined(AFX_IFILE_H__7EE73AC7_36BC_4822_93FF_44F3B0C766F6__INCLUDED_)
28 #define AFX_IFILE_H__7EE73AC7_36BC_4822_93FF_44F3B0C766F6__INCLUDED_
29
30 #pragma once
31
32 #ifdef TARGET_POSIX
33 #include "PlatformDefs.h" // for __stat64
34 #endif
35
36 #include <stdio.h>
37 #include <stdint.h>
38 #include <sys/stat.h>
39
40 #include "utils/StdString.h"
41 #include "IFileTypes.h"
42
43 class CURL;
44
45 namespace XFILE
46 {
47
48 class IFile
49 {
50 public:
51   IFile();
52   virtual ~IFile();
53
54   virtual bool Open(const CURL& url) = 0;
55   virtual bool OpenForWrite(const CURL& url, bool bOverWrite = false) { return false; };
56   virtual bool Exists(const CURL& url) = 0;
57   virtual int Stat(const CURL& url, struct __stat64* buffer) = 0;
58   virtual int Stat(struct __stat64* buffer);
59   virtual unsigned int Read(void* lpBuf, int64_t uiBufSize) = 0;
60   virtual int Write(const void* lpBuf, int64_t uiBufSize) { return -1;};
61   virtual bool ReadString(char *szLine, int iLineLength);
62   virtual int64_t Seek(int64_t iFilePosition, int iWhence = SEEK_SET) = 0;
63   virtual void Close() = 0;
64   virtual int64_t GetPosition() = 0;
65   virtual int64_t GetLength() = 0;
66   virtual void Flush() { }
67   virtual int Truncate(int64_t size) { return -1;};
68
69   /* Returns the minium size that can be read from input stream.   *
70    * For example cdrom access where access could be sector based.  *
71    * This will cause file system to buffer read requests, to       *
72    * to meet the requirement of CFile.                             *
73    * It can also be used to indicate a file system is non buffered *
74    * but accepts any read size, have it return the value 1         */
75   virtual int  GetChunkSize() {return 0;}
76
77   virtual bool SkipNext(){return false;}
78
79   virtual bool Delete(const CURL& url) { return false; }
80   virtual bool Rename(const CURL& url, const CURL& urlnew) { return false; }
81   virtual bool SetHidden(const CURL& url, bool hidden) { return false; }
82
83   virtual int IoControl(EIoControl request, void* param) { return -1; }
84
85   virtual CStdString GetContent()                            { return "application/octet-stream"; }
86   virtual std::string GetContentCharset(void)                { return ""; }
87 };
88
89 class CRedirectException
90 {
91 public:
92   IFile *m_pNewFileImp;
93   CURL  *m_pNewUrl;
94
95   CRedirectException();
96   
97   CRedirectException(IFile *pNewFileImp, CURL *pNewUrl=NULL);
98 };
99
100 }
101
102 #endif // !defined(AFX_IFILE_H__7EE73AC7_36BC_4822_93FF_44F3B0C766F6__INCLUDED_)