mirror of
https://github.com/facebook/sapling.git
synced 2024-10-06 23:07:18 +03:00
b1e51686ba
Summary: When we migrated from Hash20 to ObjectId, we didn't fix the #include structure. Clean that up. Reviewed By: genevievehelsel Differential Revision: D32977635 fbshipit-source-id: 202b02f01f22bc174c7559c22af081deb2945caa
61 lines
1.3 KiB
C++
61 lines
1.3 KiB
C++
/*
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This software may be used and distributed according to the terms of the
|
|
* GNU General Public License version 2.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <folly/io/IOBuf.h>
|
|
#include <string>
|
|
#include "eden/fs/model/Hash.h"
|
|
#include "eden/fs/model/ObjectId.h"
|
|
|
|
namespace facebook::eden {
|
|
|
|
class Blob {
|
|
public:
|
|
Blob(const ObjectId& hash, folly::IOBuf&& contents)
|
|
: hash_{hash},
|
|
contents_{std::move(contents)},
|
|
size_{contents_.computeChainDataLength()} {}
|
|
|
|
Blob(const ObjectId& hash, const folly::IOBuf& contents)
|
|
: hash_{hash},
|
|
contents_{contents},
|
|
size_{contents_.computeChainDataLength()} {}
|
|
|
|
/**
|
|
* Convenience constructor for unit tests. Always copies the given
|
|
* StringPiece.
|
|
*/
|
|
Blob(const ObjectId& hash, folly::StringPiece contents)
|
|
: hash_{hash},
|
|
contents_{folly::IOBuf::COPY_BUFFER, contents.data(), contents.size()},
|
|
size_{contents.size()} {}
|
|
|
|
const ObjectId& getHash() const {
|
|
return hash_;
|
|
}
|
|
|
|
const folly::IOBuf& getContents() const {
|
|
return contents_;
|
|
}
|
|
|
|
size_t getSize() const {
|
|
return size_;
|
|
}
|
|
|
|
size_t getSizeBytes() const {
|
|
return size_;
|
|
}
|
|
|
|
private:
|
|
const ObjectId hash_;
|
|
const folly::IOBuf contents_;
|
|
const size_t size_;
|
|
};
|
|
|
|
} // namespace facebook::eden
|