2 * SAP-Announcement Support for XBMC
3 * Copyright (c) 2008 elupus (Joakim Plate)
4 * Copyright (C) 2008-2013 Team XBMC
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)
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.
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/>.
24 #include "SAPDirectory.h"
25 #include "threads/SingleLock.h"
32 using namespace XFILE;
34 //////////////////////////////////////////////////////////////////////
35 // Construction/Destruction
36 //////////////////////////////////////////////////////////////////////
45 bool CSAPFile::Open(const CURL& url)
47 CStdString path = url.Get();
49 CSingleLock lock(g_sapsessions.m_section);
50 for(vector<CSAPSessions::CSession>::iterator it = g_sapsessions.m_sessions.begin(); it != g_sapsessions.m_sessions.end(); it++)
54 m_len = it->payload.length();
55 m_stream.str(it->payload);
66 bool CSAPFile::Exists(const CURL& url)
68 CStdString path = url.Get();
70 CSingleLock lock(g_sapsessions.m_section);
71 for(vector<CSAPSessions::CSession>::iterator it = g_sapsessions.m_sessions.begin(); it != g_sapsessions.m_sessions.end(); it++)
79 int CSAPFile::Stat(const CURL& url, struct __stat64* buffer)
81 CStdString path = url.Get();
87 memset(buffer, 0, sizeof(struct __stat64));
88 buffer->st_mode = _S_IFDIR;
94 CSingleLock lock(g_sapsessions.m_section);
95 for(vector<CSAPSessions::CSession>::iterator it = g_sapsessions.m_sessions.begin(); it != g_sapsessions.m_sessions.end(); it++)
101 memset(buffer, 0, sizeof(*buffer));
103 buffer->st_size = it->payload.size();
104 buffer->st_mode = _S_IFREG;
114 unsigned int CSAPFile::Read(void *lpBuf, int64_t uiBufSize)
116 return (unsigned int)m_stream.readsome((char*)lpBuf, (streamsize)uiBufSize);
119 void CSAPFile::Close()
123 //*********************************************************************************************
124 int64_t CSAPFile::Seek(int64_t iFilePosition, int iWhence)
129 m_stream.seekg((int)iFilePosition, ios_base::beg);
132 m_stream.seekg((int)iFilePosition, ios_base::cur);
135 m_stream.seekg((int)iFilePosition, ios_base::end);
140 return m_stream.tellg();
143 //*********************************************************************************************
144 int64_t CSAPFile::GetLength()
149 //*********************************************************************************************
150 int64_t CSAPFile::GetPosition()
152 return m_stream.tellg();
155 bool CSAPFile::Delete(const CURL& url)
157 CStdString path = url.Get();
159 CSingleLock lock(g_sapsessions.m_section);
160 for(vector<CSAPSessions::CSession>::iterator it = g_sapsessions.m_sessions.begin(); it != g_sapsessions.m_sessions.end(); it++)
164 g_sapsessions.m_sessions.erase(it);
171 bool CSAPFile::Rename(const CURL& url, const CURL& urlnew)
176 int CSAPFile::IoControl(EIoControl request, void* param)
178 if(request == IOCTRL_SEEK_POSSIBLE)