# FileStream.hpp

This File On Github
Ask A Question

API: latest
module: oatpp
#include "oatpp/core/data/stream/FileStream.hpp"

# FileInputStream

Wrapper over std::FILE.

namespace oatpp { namespace data { namespace stream { 
  class FileInputStream : public InputStream {}
}}}

# Methods

Return Type Name Summary
[none] FileInputStream Multiple implementations:
  1. Move constructor.
  2. Constructor.
  3. Constructor.
[none] ~FileInputStream Virtual destructor.
std::FILE* getFile Get file.
v_io_size read Read data from stream up to count bytes, and return number of bytes actually read.
void setInputStreamIOMode Set stream I/O mode.
IOMode getInputStreamIOMode Get stream I/O mode.
Context& getInputStreamContext Get stream context.
void close Close file.

# FileInputStream::FileInputStream

  1. Move constructor.
    • @param other
    FileInputStream(FileInputStream&& other)
    
  2. Constructor.
    • @param file - file.
    • @param ownsFile - if true then call close on FileInputStream destruction.
    • @param captureData - capture auxiliary data to not get deleted until it's done with the stream.
    FileInputStream(std::FILE* file, bool ownsFile, const std::shared_ptr<void>& captureData = nullptr)
    
  3. Constructor.
    • @param filename - name of the file.
    • @param captureData - capture auxiliary data to not get deleted until it's done with the stream.
    FileInputStream(const char* filename, const std::shared_ptr<void>& captureData = nullptr)
    

# FileInputStream::~FileInputStream

Virtual destructor.

~FileInputStream()

# FileInputStream::getFile

Get file.

  • @return

std::FILE* getFile()

# FileInputStream::read

Read data from stream up to count bytes, and return number of bytes actually read.
It is a legal case if return result < count. Caller should handle this!

  • @param data - buffer to read data to.
  • @param count - size of the buffer.
  • @param action - async specific action. If action is NOT oatpp::async::Action::TYPE_NONE, then caller MUST return this action on coroutine iteration.
  • @return - actual number of bytes read.

v_io_size read(void *data, v_buff_size count, async::Action& action) override

# FileInputStream::setInputStreamIOMode

Set stream I/O mode.

  • @throws

void setInputStreamIOMode(IOMode ioMode) override

# FileInputStream::getInputStreamIOMode

Get stream I/O mode.

  • @return

IOMode getInputStreamIOMode() override

# FileInputStream::getInputStreamContext

Get stream context.

  • @return

Context& getInputStreamContext() override

# FileInputStream::close

Close file.

void close()

# FileOutputStream

Wrapper over std::FILE.

namespace oatpp { namespace data { namespace stream { 
  class FileOutputStream : public OutputStream {}
}}}

# Methods

Return Type Name Summary
[none] FileOutputStream Multiple implementations:
  1. Move constructor.
  2. Constructor.
  3. Constructor.
[none] ~FileOutputStream Virtual destructor.
std::FILE* getFile Get file.
v_io_size write Write data to stream up to count bytes, and return number of bytes actually written.
void setOutputStreamIOMode Set stream I/O mode.
IOMode getOutputStreamIOMode Get stream I/O mode.
Context& getOutputStreamContext Get stream context.
void close Close file.

# FileOutputStream::FileOutputStream

  1. Move constructor.
    • @param other
    FileOutputStream(FileOutputStream&& other)
    
  2. Constructor.
    • @param file - file.
    • @param ownsFile - if true then call close on FileInputStream destruction.
    • @param captureData - capture auxiliary data to not get deleted until it's done with the stream.
    FileOutputStream(std::FILE* file, bool ownsFile, const std::shared_ptr<void>& captureData = nullptr)
    
  3. Constructor.
    • @param filename - name of the file.
    • @param mode - ("wb" - create new/override, "ab" - create new/append).
    • @param captureData - capture auxiliary data to not get deleted until it's done with the stream.
    FileOutputStream(const char* filename, const char* mode = "wb", const std::shared_ptr<void>& captureData = nullptr)
    

# FileOutputStream::~FileOutputStream

Virtual destructor.

~FileOutputStream()

# FileOutputStream::getFile

Get file.

  • @return

std::FILE* getFile()

# FileOutputStream::write

Write data to stream up to count bytes, and return number of bytes actually written.
It is a legal case if return result < count. Caller should handle this!

  • @param data - data to write.
  • @param count - number of bytes to write.
  • @param action - async specific action. If action is NOT oatpp::async::Action::TYPE_NONE, then caller MUST return this action on coroutine iteration.
  • @return - actual number of bytes written. oatpp::v_io_size.

v_io_size write(const void *data, v_buff_size count, async::Action& action) override

# FileOutputStream::setOutputStreamIOMode

Set stream I/O mode.

  • @throws

void setOutputStreamIOMode(IOMode ioMode) override

# FileOutputStream::getOutputStreamIOMode

Get stream I/O mode.

  • @return

IOMode getOutputStreamIOMode() override

# FileOutputStream::getOutputStreamContext

Get stream context.

  • @return

Context& getOutputStreamContext() override

# FileOutputStream::close

Close file.

void close()