mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-11 00:36:20 +02:00
d1b0909894
This allows readFile() to indicate that a file doesn't exist, and might eliminate some large string copying.
48 lines
831 B
C++
48 lines
831 B
C++
#pragma once
|
|
|
|
#include "types.hh"
|
|
|
|
#include <string>
|
|
|
|
namespace nix {
|
|
|
|
struct DownloadOptions
|
|
{
|
|
string expectedETag;
|
|
bool verifyTLS{true};
|
|
enum { yes, no, automatic } showProgress{yes};
|
|
bool head{false};
|
|
};
|
|
|
|
struct DownloadResult
|
|
{
|
|
bool cached;
|
|
string etag;
|
|
std::shared_ptr<std::string> data;
|
|
};
|
|
|
|
class Store;
|
|
|
|
struct Downloader
|
|
{
|
|
virtual DownloadResult download(string url, const DownloadOptions & options) = 0;
|
|
|
|
Path downloadCached(ref<Store> store, const string & url, bool unpack);
|
|
|
|
enum Error { NotFound, Forbidden, Misc };
|
|
};
|
|
|
|
ref<Downloader> makeDownloader();
|
|
|
|
class DownloadError : public Error
|
|
{
|
|
public:
|
|
Downloader::Error error;
|
|
DownloadError(Downloader::Error error, const FormatOrString & fs)
|
|
: Error(fs), error(error)
|
|
{ }
|
|
};
|
|
|
|
bool isUri(const string & s);
|
|
|
|
}
|