kodi
TVOSFile.h
1 #pragma once
2 /*
3  * Copyright (C) 2016 Team Kodi
4  * http://kodi.tv
5  *
6  * This Program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * This Program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with Kodi; see the file COPYING. If not, see
18  * <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #include "URL.h"
23 #include "filesystem/IFile.h"
24 
25 #include "platform/posix/filesystem/PosixFile.h"
26 
27 namespace XFILE
28 {
29 class CTVOSFile : public IFile
30 {
31 public:
32  CTVOSFile() {}
33  ~CTVOSFile();
34 
35  bool static WantsFile(const CURL& url);
36 
37  bool Open(const CURL& url) override;
38  bool Exists(const CURL& url) override;
39  int Stat(const CURL& url, struct __stat64* buffer) override;
40  int Stat(struct __stat64* buffer) override;
41  bool OpenForWrite(const CURL& url, bool bOverWrite = false) override;
42  bool Delete(const CURL& url) override;
43  bool Rename(const CURL& url, const CURL& urlnew) override;
44 
45  ssize_t Read(void* lpBuf, size_t uiBufSize) override;
46  ssize_t Write(const void* lpBuf, size_t uiBufSize) override;
47  int64_t Seek(int64_t iFilePosition, int iWhence = SEEK_SET) override;
48  void Close() override;
49  int64_t GetPosition() override;
50  int64_t GetLength() override;
51  int GetChunkSize() override;
52  int IoControl(EIoControl request, void* param) override;
53 
54 protected:
55  CURL m_url;
56  int64_t m_position = -1;
57  CPosixFile* m_pFallbackFile = nullptr;
58  struct __stat64 m_cachedStat;
59 
60  int CacheStat(const CURL& url, struct __stat64* buffer);
61 };
62 } // namespace XFILE
Definition: TVOSFile.h:29
Definition: Scraper.h:41
Definition: PosixFile.h:16
Definition: URL.h:21
Definition: IFile.h:42
ssize_t Write(const void *lpBuf, size_t uiBufSize) override
Attempt to write bufSize bytes from buffer bufPtr into currently opened file.
Definition: TVOSFile.cpp:199
int Stat(const CURL &url, struct __stat64 *buffer) override
Fills struct __stat64 with information about file specified by url.
Definition: TVOSFile.cpp:124
ssize_t Read(void *lpBuf, size_t uiBufSize) override
Attempt to read bufSize bytes from currently opened file into buffer bufPtr.
Definition: TVOSFile.cpp:174