2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
13 #include <udfread/udfread.h>
15 using namespace XFILE
;
17 CUDFFile::CUDFFile() : m_bi
{std::make_unique
<CUDFBlockInput
>()}
21 bool CUDFFile::Open(const CURL
& url
)
26 m_udf
= udfread_init();
31 auto bi
= m_bi
->GetBlockInput(url
.GetHostName());
39 if (udfread_open_input(m_udf
, bi
) < 0)
46 m_file
= udfread_file_open(m_udf
, url
.GetFileName().c_str());
56 void CUDFFile::Close()
60 udfread_file_close(m_file
);
71 int CUDFFile::Stat(const CURL
& url
, struct __stat64
* buffer
)
73 if (!m_udf
|| !m_file
|| !buffer
)
77 buffer
->st_size
= GetLength();
82 ssize_t
CUDFFile::Read(void* buffer
, size_t size
)
84 return udfread_file_read(m_file
, buffer
, size
);
87 int64_t CUDFFile::Seek(int64_t filePosition
, int whence
)
89 return udfread_file_seek(m_file
, filePosition
, whence
);
92 int64_t CUDFFile::GetLength()
94 return udfread_file_size(m_file
);
97 int64_t CUDFFile::GetPosition()
99 return udfread_file_tell(m_file
);
102 bool CUDFFile::Exists(const CURL
& url
)