Base Framework
Public Types | Public Member Functions | List of all members
FileOutputStream Class Reference

File output stream. More...

#include <base/io/FileOutputStream.h>

Inherits Object, and OutputStream.

Public Types

enum  Options {
  CREATE = File::CREATE, TRUNCATE = File::TRUNCATE, EXCLUSIVE = File::EXCLUSIVE, ASYNCHRONOUS = File::ASYNCHRONOUS,
  APPEND = File::APPEND
}
 
enum  Permissions {
  RWXU = 0x700, RUSR = 0x400, WUSR = 0x200, XUSR = 0x100,
  RWXG = 0x70, RGRP = 0x40, WGRP = 0x20, XGRP = 0x10,
  RWXO = 0x7, ROTH = 0x4, WOTH = 0x2, XOTH = 0x1
}
 

Public Member Functions

 FileOutputStream (const String &path, unsigned int options=CREATE|TRUNCATE, unsigned int permissions=0x640)
 
 FileOutputStream (const FileOutputStream &copy) noexcept
 
bool open (const String &path, unsigned int options=CREATE|TRUNCATE, unsigned int permissions=0x640)
 
FileOutputStreamoperator= (const FileOutputStream &assign) noexcept
 
bool isOpen () const noexcept
 
void close ()
 
void flush ()
 
unsigned int write (const uint8 *buffer, unsigned int count, bool nonblocking=false)
 
- Public Member Functions inherited from Stream
virtual ~Stream () noexcept(false)
 
- Public Member Functions inherited from ReferenceCountedObject
 ReferenceCountedObject () noexcept
 
 ReferenceCountedObject (const ReferenceCountedObject &copy) noexcept
 
 ReferenceCountedObject (ReferenceCountedObject &&move) noexcept
 
ReferenceCountedObjectoperator= (const ReferenceCountedObject &copy) noexcept
 
ReferenceCountedObjectoperator= (ReferenceCountedObject &&move) noexcept
 
MemorySize getNumberOfReferences_INTERNAL () const noexcept
 
virtual bool useGarbageCollector () const noexcept
 
- Public Member Functions inherited from DynamicObject
 DynamicObject () noexcept
 
bool isValidObject () const noexcept
 
virtual ~DynamicObject () noexcept(false)
 
 _COM_AZURE_DEV__BASE__OVERRIDE_ALLOC ()
 

Detailed Description

File output stream.

Output stream with a file as the destination.

Version
1.0

Member Enumeration Documentation

◆ Options

File initialization flags.

Enumerator
CREATE 

Specifies that the file should be created if it doesn't exist.

TRUNCATE 

Specifies that the file should be truncated if it already exists.

EXCLUSIVE 

Specifies that the file should be opened in exclusive mode.

ASYNCHRONOUS 

Specifies that the file should be opened for asynchronous IO (disables the synchronous IO interface).

APPEND 

Specifies that data should be appended to the file.

◆ Permissions

Permissions.

Enumerator
RWXU 

Read, write, and execute permissions for the owner of the file.

RUSR 

Read permission for the owner of the file.

WUSR 

Write permission for the owner of the file.

XUSR 

Execute permission for the owner of the file.

RWXG 

Read, write, and execute permissions for the group associated with the file.

RGRP 

Read permission for the group associated with the file.

WGRP 

Write permission for the group associated with the file.

XGRP 

Execute permission for the group associated with the file.

RWXO 

Read, write, and execute permissions for other users.

ROTH 

Read permission for other users.

WOTH 

Write permission for other users.

XOTH 

Execute permission for other users.

Constructor & Destructor Documentation

◆ FileOutputStream()

FileOutputStream::FileOutputStream ( const String path,
unsigned int  options = CREATE|TRUNCATE,
unsigned int  permissions = 0x640 
)

Initializes the file output stream.

Parameters
pathThe name of the file.
optionsThe flags used to open the file (CREATE, TRUNCATE, APPEND, NONBLOCK, and SYNC).
permissionsSpecifies the permissions to be used if the file is created.

Member Function Documentation

◆ close()

void FileOutputStream::close ( )
virtual

Closes the stream and releases any system resources associated with the stream.

Implements Stream.

◆ flush()

void FileOutputStream::flush ( )
inlinevirtual

Forces any buffered bytes to be written out.

Implements OutputStream.

◆ isOpen()

bool FileOutputStream::isOpen ( ) const
noexcept

Returns true if open.

◆ open()

bool FileOutputStream::open ( const String path,
unsigned int  options = CREATE|TRUNCATE,
unsigned int  permissions = 0x640 
)

Open the file output stream.

Parameters
pathThe name of the file.
optionsThe flags used to open the file (CREATE, TRUNCATE, APPEND, NONBLOCK, and SYNC).
permissionsSpecifies the permissions to be used if the file is created.

◆ write()

unsigned int FileOutputStream::write ( const uint8 *  buffer,
unsigned int  size,
bool  nonblocking = false 
)
inlinevirtual

Writes the specified number of bytes in the buffer to the stream. In blocking mode the method does not return until all bytes have been written. In non-blocking mode the total number of bytes written may be any number below or equal to the requested number of bytes.

Parameters
bufferThe buffer containing the bytes to be written.
sizeThe number of bytes to be written.
nonblockingSpecifies that the method may not block.
Returns
The actual number of bytes written to the stream.

Implements OutputStream.