From 7c1c779cfd01162d020d0c276bb605adfe338df9 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Wed, 5 Oct 2022 16:09:31 +0200 Subject: Add load_entire_file option for file inputs --- src/input/File.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/input/File.h') diff --git a/src/input/File.h b/src/input/File.h index 39ce7fd..f317d46 100644 --- a/src/input/File.h +++ b/src/input/File.h @@ -2,7 +2,7 @@ Copyright (C) 2009 Her Majesty the Queen in Right of Canada (Communications Research Center Canada) - Copyright (C) 2018 Matthias P. Braendli + Copyright (C) 2022 Matthias P. Braendli http://www.opendigitalradio.org */ @@ -43,23 +43,32 @@ class FileBase : public InputBase { virtual void close(); virtual void setNonblocking(bool nonblock); + virtual void setLoadEntireFile(bool load_entire_file); + protected: /* Rewind the file * Returns -1 on failure, 0 on success */ - virtual int rewind(); - protected: + virtual ssize_t rewind(); /* Read len bytes from the file into buf, and return * the number of bytes read, or -1 in case of error. */ virtual ssize_t readFromFile(uint8_t* buf, size_t len); + virtual ssize_t load_entire_file(); + // We use unix open() instead of fopen() because // of non-blocking I/O int m_fd = -1; + std::string m_filename; bool m_nonblock = false; + bool m_load_entire_file = false; std::vector m_nonblock_buffer; + + size_t m_file_contents_offset = 0; + std::vector m_file_contents; + bool m_file_open_alert_shown = false; }; class MPEGFile : public FileBase { -- cgit v1.2.3