Merge pull request #25808 from CastagnaIT/fix_url_parse
[xbmc.git] / xbmc / filesystem / PipeFile.h
blob507006b374f3eb5353b8d02d9111ad507057c770
1 /*
2 * Copyright (c) 2002 Frodo
3 * Portions Copyright (c) by the authors of ffmpeg and xvid
4 * Copyright (C) 2002-2018 Team Kodi
5 * This file is part of Kodi - https://kodi.tv
7 * SPDX-License-Identifier: GPL-2.0-or-later
8 * See LICENSES/README.md for more information.
9 */
11 #pragma once
13 // FilePipe.h: interface for the CPipeFile class.
15 //////////////////////////////////////////////////////////////////////
17 #include "IFile.h"
18 #include "PipesManager.h"
19 #include "threads/CriticalSection.h"
21 #include <string>
22 #include <vector>
24 namespace XFILE
27 class CPipeFile : public IFile, public IPipeListener
29 public:
30 CPipeFile();
31 ~CPipeFile() override;
32 int64_t GetPosition() override;
33 int64_t GetLength() override;
34 virtual void SetLength(int64_t len);
35 bool Open(const CURL& url) override;
36 bool Exists(const CURL& url) override;
37 int Stat(const CURL& url, struct __stat64* buffer) override;
38 int Stat(struct __stat64* buffer) override;
39 ssize_t Read(void* lpBuf, size_t uiBufSize) override;
40 ssize_t Write(const void* lpBuf, size_t uiBufSize) override;
41 int64_t Seek(int64_t iFilePosition, int iWhence = SEEK_SET) override;
42 void Close() override;
43 void Flush() override;
44 virtual int64_t GetAvailableRead();
46 bool OpenForWrite(const CURL& url, bool bOverWrite = false) override;
48 bool Delete(const CURL& url) override;
49 bool Rename(const CURL& url, const CURL& urlnew) override;
50 int IoControl(EIoControl request, void* param) override;
52 std::string GetName() const;
54 void OnPipeOverFlow() override;
55 void OnPipeUnderFlow() override;
57 void AddListener(IPipeListener *l);
58 void RemoveListener(IPipeListener *l);
60 void SetEof();
61 bool IsEof();
62 bool IsEmpty();
63 bool IsClosed();
65 void SetOpenThreshold(int threshold);
67 protected:
68 int64_t m_pos = 0;
69 int64_t m_length = -1;
71 XFILE::Pipe *m_pipe;
73 CCriticalSection m_lock;
74 std::vector<XFILE::IPipeListener *> m_listeners;