5 #ifndef CVMFS_INGESTION_INGESTION_SOURCE_H_
6 #define CVMFS_INGESTION_INGESTION_SOURCE_H_
41 virtual std::string
GetPath()
const = 0;
43 virtual bool Open() = 0;
44 virtual ssize_t
Read(
void* buffer,
size_t nbyte) = 0;
45 virtual bool Close() = 0;
62 "Err: Impossible to open the file: %s (%d)\n %s",
path_.c_str(),
63 errno, strerror(errno));
69 ssize_t
Read(
void* buffer,
size_t nbyte) {
74 path_.c_str(), errno, strerror(errno));
80 if (
fd_ == -1)
return true;
93 *size =
stat_.st_size;
98 *size =
stat_.st_size;
119 const std::string &p,
const unsigned char *d,
unsigned s)
124 virtual bool Open() {
return true; }
125 virtual ssize_t
Read(
void* buffer,
size_t nbyte) {
127 size_t size = std::min(remaining, nbyte);
128 if (size > 0) memcpy(buffer,
data_ + pos_, size);
130 return static_cast<ssize_t
>(
size);
132 virtual bool Close() {
return true; }
150 source_(
"MEM", reinterpret_cast<const unsigned char*>(
data_.data()),
154 source_(filename, reinterpret_cast<const unsigned char*>(
data_.data()),
160 virtual ssize_t
Read(
void* buffer,
size_t nbyte) {
175 struct archive_entry* entry,
Signal* read_archive_signal)
180 const struct stat* stat_ = archive_entry_stat(entry);
181 size_ = stat_->st_size;
192 ssize_t
Read(
void* external_buffer,
size_t nbytes) {
193 ssize_t read = archive_read_data(
archive_, external_buffer, nbytes);
197 "failed to read data from the tar entry: %s (%d)\n %s",
220 #endif // CVMFS_INGESTION_INGESTION_SOURCE_H_
virtual bool GetSize(uint64_t *size)
std::string GetPath() const
virtual bool IsRealFile() const
MemoryIngestionSource(const std::string &p, const unsigned char *d, unsigned s)
FileIngestionSource(const std::string &path)
virtual bool IsRealFile() const
virtual ~MemoryIngestionSource()
virtual ssize_t Read(void *buffer, size_t nbyte)
assert((mem||(size==0))&&"Out Of Memory")
virtual bool GetSize(uint64_t *size)=0
virtual std::string GetPath() const
StringIngestionSource(const std::string &data)
StringIngestionSource(const std::string &data, const std::string &filename)
bool GetSize(uint64_t *size)
struct archive * archive_
ssize_t SafeRead(int fd, void *buf, size_t nbyte)
virtual bool IsRealFile() const
virtual ~StringIngestionSource()
const unsigned char * data_
virtual std::string GetPath() const =0
virtual bool IsRealFile() const =0
ssize_t Read(void *external_buffer, size_t nbytes)
TarIngestionSource(const std::string &path, struct archive *archive, struct archive_entry *entry, Signal *read_archive_signal)
virtual ssize_t Read(void *buffer, size_t nbyte)=0
ssize_t Read(void *buffer, size_t nbyte)
virtual bool GetSize(uint64_t *size)
virtual bool IsRealFile() const
bool GetSize(uint64_t *size)
Signal * read_archive_signal_
virtual ~IngestionSource()
std::string GetPath() const
virtual std::string GetPath() const
MemoryIngestionSource source_
virtual ssize_t Read(void *buffer, size_t nbyte)
CVMFS_EXPORT void LogCvmfs(const LogSource source, const int mask, const char *format,...)