CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/Core/FileLoaders/HTTPFileLoader.h
Views: 1401
// Copyright (c) 2012- PPSSPP Project.12// This program is free software: you can redistribute it and/or modify3// it under the terms of the GNU General Public License as published by4// the Free Software Foundation, version 2.0 or later versions.56// This program is distributed in the hope that it will be useful,7// but WITHOUT ANY WARRANTY; without even the implied warranty of8// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9// GNU General Public License 2.0 for more details.1011// A copy of the GPL 2.0 should have been included with the program.12// If not, see http://www.gnu.org/licenses/1314// Official git repository and contact information can be found at15// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.1617#pragma once1819#include <mutex>20#include <vector>2122#include "Common/File/Path.h"23#include "Common/Net/HTTPClient.h"24#include "Common/Net/Resolve.h"25#include "Common/Net/URL.h"26#include "Common/CommonTypes.h"27#include "Core/Loaders.h"2829class HTTPFileLoader : public FileLoader {30public:31HTTPFileLoader(const ::Path &filename);32~HTTPFileLoader();3334bool IsRemote() override {35return true;36}37bool Exists() override;38bool ExistsFast() override;39bool IsDirectory() override;40s64 FileSize() override;41Path GetPath() const override;4243size_t ReadAt(s64 absolutePos, size_t bytes, size_t count, void *data, Flags flags = Flags::NONE) override {44return ReadAt(absolutePos, bytes * count, data, flags) / bytes;45}46size_t ReadAt(s64 absolutePos, size_t bytes, void *data, Flags flags = Flags::NONE) override;4748void Cancel() override {49cancel_ = true;50}5152std::string LatestError() const override {53return latestError_;54}5556private:57void Prepare();58int SendHEAD(const Url &url, std::vector<std::string> &responseHeaders);5960void Connect(double timeout);6162void Disconnect() {63if (connected_) {64client_.Disconnect();65}66connected_ = false;67}6869s64 filesize_ = 0;70s64 filepos_ = 0;71Url url_;72http::Client client_;73net::RequestProgress progress_;74::Path filename_;75bool connected_ = false;76bool cancel_ = false;77const char *latestError_ = "";7879std::once_flag preparedFlag_;80std::mutex readAtMutex_;81};828384