2 * Copyright (C) 2010 Team Boxee
5 * Copyright (C) 2010-2013 Team XBMC
8 * This Program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
13 * This Program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with XBMC; see the file COPYING. If not, see
20 * <http://www.gnu.org/licenses/>.
31 using namespace XFILE;
33 //////////////////////////////////////////////////////////////////////
34 // Construction/Destruction
35 //////////////////////////////////////////////////////////////////////
36 //*********************************************************************************************
42 //*********************************************************************************************
50 //*********************************************************************************************
51 bool CUDFFile::Open(const CURL& url)
53 if(!m_udfIsoReaderLocal.Open(url.GetHostName()))
56 m_hFile = m_udfIsoReaderLocal.OpenFile(url.GetFileName());
57 if (m_hFile == INVALID_HANDLE_VALUE)
67 //*********************************************************************************************
68 unsigned int CUDFFile::Read(void *lpBuf, int64_t uiBufSize)
70 if (!m_bOpened) return 0;
71 char *pData = (char *)lpBuf;
73 int iResult = m_udfIsoReaderLocal.ReadFile( m_hFile, (unsigned char*)pData, (long)uiBufSize);
79 //*********************************************************************************************
80 void CUDFFile::Close()
82 if (!m_bOpened) return ;
83 m_udfIsoReaderLocal.CloseFile( m_hFile);
87 //*********************************************************************************************
88 int64_t CUDFFile::Seek(int64_t iFilePosition, int iWhence)
90 if (!m_bOpened) return -1;
91 int64_t lNewPos = m_udfIsoReaderLocal.Seek(m_hFile, iFilePosition, iWhence);
95 //*********************************************************************************************
96 int64_t CUDFFile::GetLength()
98 if (!m_bOpened) return -1;
99 return m_udfIsoReaderLocal.GetFileSize(m_hFile);
102 //*********************************************************************************************
103 int64_t CUDFFile::GetPosition()
105 if (!m_bOpened) return -1;
106 return m_udfIsoReaderLocal.GetFilePosition(m_hFile);
109 bool CUDFFile::Exists(const CURL& url)
111 if(!m_udfIsoReaderLocal.Open(url.GetHostName()))
114 m_hFile = m_udfIsoReaderLocal.OpenFile(url.GetFileName());
115 if (m_hFile == INVALID_HANDLE_VALUE)
118 m_udfIsoReaderLocal.CloseFile(m_hFile);
119 m_hFile = INVALID_HANDLE_VALUE;
123 int CUDFFile::Stat(const CURL& url, struct __stat64* buffer)
125 if(!m_udfIsoReaderLocal.Open(url.GetHostName()))
128 m_hFile = m_udfIsoReaderLocal.OpenFile(url.GetFileName());
129 if (m_hFile != INVALID_HANDLE_VALUE)
131 buffer->st_size = m_udfIsoReaderLocal.GetFileSize(m_hFile);
132 buffer->st_mode = _S_IFREG;
133 m_udfIsoReaderLocal.CloseFile(m_hFile);