[windows] Fix MAC Address Discovery
[xbmc.git] / xbmc / filesystem / FileCache.h
blobd28a6df8dd93ff33ec2c6f156335efc6d95a4af5
1 /*
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.
7 */
9 #pragma once
11 #include "CacheStrategy.h"
12 #include "File.h"
13 #include "IFile.h"
14 #include "threads/CriticalSection.h"
15 #include "threads/Thread.h"
17 #include <atomic>
18 #include <chrono>
19 #include <memory>
21 using namespace std::chrono_literals;
23 namespace XFILE
26 class CFileCache : public IFile, public CThread
28 public:
29 explicit CFileCache(const unsigned int flags);
30 ~CFileCache() override;
32 // CThread methods
33 void Process() override;
34 void OnExit() override;
35 void StopThread(bool bWait = true) override;
37 // IFIle methods
38 bool Open(const CURL& url) override;
39 void Close() override;
40 bool Exists(const CURL& url) override;
41 int Stat(const CURL& url, struct __stat64* buffer) override;
43 ssize_t Read(void* lpBuf, size_t uiBufSize) override;
45 int64_t Seek(int64_t iFilePosition, int iWhence) override;
46 int64_t GetPosition() override;
47 int64_t GetLength() override;
49 int IoControl(EIoControl request, void* param) override;
51 IFile *GetFileImp();
53 const std::string GetProperty(XFILE::FileProperty type, const std::string &name = "") const override;
55 const std::vector<std::string> GetPropertyValues(XFILE::FileProperty type, const std::string& name = "") const override
57 return std::vector<std::string>();
60 private:
61 std::unique_ptr<CCacheStrategy> m_pCache;
62 int m_seekPossible = 0;
63 CFile m_source;
64 std::string m_sourcePath;
65 CEvent m_seekEvent;
66 CEvent m_seekEnded;
67 int64_t m_nSeekResult = 0;
68 int64_t m_seekPos = 0;
69 int64_t m_readPos = 0;
70 int64_t m_writePos = 0;
71 unsigned m_chunkSize = 0;
72 uint32_t m_writeRate = 0;
73 uint32_t m_writeRateActual = 0;
74 uint32_t m_writeRateLowSpeed = 0;
75 int64_t m_forwardCacheSize = 0;
76 int64_t m_maxForward = 0;
77 bool m_bFilling = false;
78 std::atomic<int64_t> m_fileSize;
79 unsigned int m_flags;
80 CCriticalSection m_sync;
81 std::chrono::milliseconds m_processWait{100ms};