7#include <packager/file/callback_file.h>
11#include <absl/log/log.h>
13#include <packager/file.h>
14#include <packager/macros/compiler.h>
19 : File(file_name), file_mode_(mode) {}
21CallbackFile::~CallbackFile() {}
23bool CallbackFile::Close() {
28int64_t CallbackFile::Read(
void* buffer, uint64_t length) {
29 if (!callback_params_->read_func) {
30 LOG(ERROR) <<
"Read function not defined.";
33 return callback_params_->read_func(name_, buffer, length);
36int64_t CallbackFile::Write(
const void* buffer, uint64_t length) {
37 if (!callback_params_->write_func) {
38 LOG(ERROR) <<
"Write function not defined.";
41 return callback_params_->write_func(name_, buffer, length);
44void CallbackFile::CloseForWriting() {}
46int64_t CallbackFile::Size() {
47 LOG(INFO) <<
"CallbackFile does not support Size().";
51bool CallbackFile::Flush() {
56bool CallbackFile::Seek(uint64_t position) {
58 VLOG(1) <<
"CallbackFile does not support Seek().";
62bool CallbackFile::Tell(uint64_t* position) {
64 VLOG(1) <<
"CallbackFile does not support Tell().";
68bool CallbackFile::Open() {
69 if (file_mode_ !=
"r" && file_mode_ !=
"w" && file_mode_ !=
"rb" &&
71 LOG(ERROR) <<
"CallbackFile does not support file mode " << file_mode_;
74 return ParseCallbackFileName(file_name(), &callback_params_, &name_);
CallbackFile(const char *file_name, const char *mode)
All the methods that are virtual are virtual for mocking.