Files
revng-revng/lib/Storage/S3StorageClient.h
Giacomo Vercesi 93d3a6238d revng: introduce S3 support
Add the capability for all revng tooling to run with an S3-backed
workdir.
2023-09-06 15:23:43 +02:00

60 lines
1.5 KiB
C++

#pragma once
//
// This file is distributed under the MIT License. See LICENSE.md for details.
//
#include "aws/s3/S3Client.h"
#include "llvm/ADT/StringRef.h"
#include "revng/Storage/StorageClient.h"
namespace revng {
class S3WritableFile;
class S3StorageClient : public StorageClient {
private:
Aws::S3::S3Client Client;
std::string Bucket;
std::string SubPath;
std::string RedactedURL;
llvm::StringMap<std::string> FilenameMap;
static constexpr auto IndexName = "index.yml";
public:
S3StorageClient(llvm::StringRef URL);
~S3StorageClient() override = default;
static llvm::Expected<std::unique_ptr<S3StorageClient>>
fromURL(llvm::StringRef URL);
static bool isS3URL(llvm::StringRef Input) {
return Input.starts_with("s3://") or Input.starts_with("s3s://");
}
llvm::Expected<PathType> type(llvm::StringRef Path) override;
llvm::Error createDirectory(llvm::StringRef Path) override;
llvm::Error remove(llvm::StringRef Path) override;
llvm::sys::path::Style getStyle() const override;
llvm::Error copy(llvm::StringRef Source,
llvm::StringRef Destination) override;
llvm::Expected<std::unique_ptr<ReadableFile>>
getReadableFile(llvm::StringRef Path) override;
llvm::Expected<std::unique_ptr<WritableFile>>
getWritableFile(llvm::StringRef Path, ContentEncoding Encoding) override;
llvm::Error commit() override;
private:
std::string dumpString() const override;
std::string resolvePath(llvm::StringRef Path);
friend class S3WritableFile;
};
} // namespace revng