Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:54:52

0001 ///////////////////////////////////////////////////////////////////////////////
0002 // Copyright (c) Lewis Baker
0003 // Licenced under MIT license. See LICENSE.txt for details.
0004 ///////////////////////////////////////////////////////////////////////////////
0005 #ifndef CPPCORO_READABLE_FILE_HPP_INCLUDED
0006 #define CPPCORO_READABLE_FILE_HPP_INCLUDED
0007 
0008 #include <cppcoro/file.hpp>
0009 #include <cppcoro/file_read_operation.hpp>
0010 #include <cppcoro/cancellation_token.hpp>
0011 
0012 namespace cppcoro
0013 {
0014     class readable_file : virtual public file
0015     {
0016     public:
0017 
0018         /// Read some data from the file.
0019         ///
0020         /// Reads \a byteCount bytes from the file starting at \a offset
0021         /// into the specified \a buffer.
0022         ///
0023         /// \param offset
0024         /// The offset within the file to start reading from.
0025         /// If the file has been opened using file_buffering_mode::unbuffered
0026         /// then the offset must be a multiple of the file-system's sector size.
0027         ///
0028         /// \param buffer
0029         /// The buffer to read the file contents into.
0030         /// If the file has been opened using file_buffering_mode::unbuffered
0031         /// then the address of the start of the buffer must be a multiple of
0032         /// the file-system's sector size.
0033         ///
0034         /// \param byteCount
0035         /// The number of bytes to read from the file.
0036         /// If the file has been opeend using file_buffering_mode::unbuffered
0037         /// then the byteCount must be a multiple of the file-system's sector size.
0038         ///
0039         /// \param ct
0040         /// An optional cancellation_token that can be used to cancel the
0041         /// read operation before it completes.
0042         ///
0043         /// \return
0044         /// An object that represents the read-operation.
0045         /// This object must be co_await'ed to start the read operation.
0046         [[nodiscard]]
0047         file_read_operation read(
0048             std::uint64_t offset,
0049             void* buffer,
0050             std::size_t byteCount) const noexcept;
0051         [[nodiscard]]
0052         file_read_operation_cancellable read(
0053             std::uint64_t offset,
0054             void* buffer,
0055             std::size_t byteCount,
0056             cancellation_token ct) const noexcept;
0057 
0058     protected:
0059 
0060         using file::file;
0061 
0062     };
0063 }
0064 
0065 #endif