7 #include <packager/file/callback_file.h>
9 #include <absl/log/log.h>
11 #include <packager/macros/compiler.h>
12 #include <packager/macros/logging.h>
17 : File(file_name), file_mode_(mode) {}
19 CallbackFile::~CallbackFile() {}
21 bool CallbackFile::Close() {
26 int64_t CallbackFile::Read(
void* buffer, uint64_t length) {
27 if (!callback_params_->read_func) {
28 LOG(ERROR) <<
"Read function not defined.";
31 return callback_params_->read_func(name_, buffer, length);
34 int64_t CallbackFile::Write(
const void* buffer, uint64_t length) {
35 if (!callback_params_->write_func) {
36 LOG(ERROR) <<
"Write function not defined.";
39 return callback_params_->write_func(name_, buffer, length);
42 void CallbackFile::CloseForWriting() {}
44 int64_t CallbackFile::Size() {
45 LOG(INFO) <<
"CallbackFile does not support Size().";
49 bool CallbackFile::Flush() {
54 bool CallbackFile::Seek(uint64_t position) {
56 VLOG(1) <<
"CallbackFile does not support Seek().";
60 bool CallbackFile::Tell(uint64_t* position) {
62 VLOG(1) <<
"CallbackFile does not support Tell().";
66 bool CallbackFile::Open() {
67 if (file_mode_ !=
"r" && file_mode_ !=
"w" && file_mode_ !=
"rb" &&
69 LOG(ERROR) <<
"CallbackFile does not support file mode " << file_mode_;
72 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.