Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:12:11

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