Merge pull request #5095 from koying/fixdroidappcrash
[vuplus_xbmc] / xbmc / filesystem / SpecialProtocolFile.cpp
1 /*
2  *      Copyright (C) 2005-2013 Team XBMC
3  *      http://xbmc.org
4  *
5  *  This Program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2, or (at your option)
8  *  any later version.
9  *
10  *  This Program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with XBMC; see the file COPYING.  If not, see
17  *  <http://www.gnu.org/licenses/>.
18  *
19  */
20
21 #include "SpecialProtocolFile.h"
22 #include "SpecialProtocol.h"
23 #include "URL.h"
24
25 #include <sys/stat.h>
26
27 using namespace XFILE;
28
29 CSpecialProtocolFile::CSpecialProtocolFile(void)
30 {
31 }
32
33 CSpecialProtocolFile::~CSpecialProtocolFile(void)
34 {
35   Close();
36 }
37
38 bool CSpecialProtocolFile::Open(const CURL& url)
39 {
40   CStdString strFileName=CSpecialProtocol::TranslatePath(url);
41
42   return m_file.Open(strFileName);
43 }
44
45 bool CSpecialProtocolFile::OpenForWrite(const CURL& url, bool bOverWrite /*=false */)
46 {
47   CStdString strFileName=CSpecialProtocol::TranslatePath(url);
48
49   return m_file.OpenForWrite(strFileName,bOverWrite);
50 }
51
52 bool CSpecialProtocolFile::Delete(const CURL& url)
53 {
54   CStdString strFileName=CSpecialProtocol::TranslatePath(url);
55   
56   return m_file.Delete(strFileName);
57 }
58
59 bool CSpecialProtocolFile::Exists(const CURL& url)
60 {
61   CStdString strFileName=CSpecialProtocol::TranslatePath(url);
62
63   return m_file.Exists(strFileName);
64 }
65
66 int CSpecialProtocolFile::Stat(const CURL& url, struct __stat64* buffer)
67 {
68   CStdString strFileName=CSpecialProtocol::TranslatePath(url);
69
70   return m_file.Stat(strFileName, buffer);
71 }
72
73 bool CSpecialProtocolFile::Rename(const CURL& url, const CURL& urlnew)
74 {
75   CStdString strFileName=CSpecialProtocol::TranslatePath(url);
76   CStdString strFileName2=CSpecialProtocol::TranslatePath(urlnew);
77
78   return m_file.Rename(strFileName,strFileName2);
79 }
80
81 int CSpecialProtocolFile::Stat(struct __stat64* buffer)
82 {
83   return m_file.Stat(buffer);
84 }
85
86 unsigned int CSpecialProtocolFile::Read(void* lpBuf, int64_t uiBufSize)
87 {
88   return m_file.Read(lpBuf, uiBufSize);
89 }
90   
91 int CSpecialProtocolFile::Write(const void* lpBuf, int64_t uiBufSize)
92 {
93   return m_file.Write(lpBuf,uiBufSize);
94 }
95
96 int64_t CSpecialProtocolFile::Seek(int64_t iFilePosition, int iWhence /*=SEEK_SET*/)
97 {
98   return m_file.Seek(iFilePosition, iWhence);
99 }
100
101 void CSpecialProtocolFile::Close()
102 {
103   m_file.Close();
104 }
105
106 int64_t CSpecialProtocolFile::GetPosition()
107 {
108   return m_file.GetPosition();
109 }
110
111 int64_t CSpecialProtocolFile::GetLength()
112 {
113   return m_file.GetLength();
114 }
115
116
117