Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
FileOutputStream.h File Reference
#include "Stroika/Foundation/StroikaPreComp.h"
#include <filesystem>
#include "Stroika/Foundation/Characters/String.h"
#include "Stroika/Foundation/Execution/Synchronized.h"
#include "Stroika/Foundation/IO/FileSystem/FileStream.h"
#include "Stroika/Foundation/Streams/OutputStream.h"
#include "FileOutputStream.inl"

Go to the source code of this file.

Namespaces

namespace  Stroika::Foundation
 

Typedefs

using Stroika::Foundation::IO::FileSystem ::FileOutputStream::Ptr = Streams::OutputStream::Ptr< byte >
 

Enumerations

enum class  Stroika::Foundation::IO::FileSystem ::FileOutputStream::FlushFlag
 
enum class  Stroika::Foundation::IO::FileSystem ::FileOutputStream::AppendFlag
 

Functions

Ptr Stroika::Foundation::IO::FileSystem ::FileOutputStream::New (const filesystem::path &fileName, FlushFlag flushFlag=FlushFlag::eDEFAULT)
 

Detailed Description

TODO:

Definition in file FileOutputStream.h.

Typedef Documentation

◆ Ptr

using Stroika::Foundation::IO::FileSystem ::FileOutputStream::Ptr = typedef Streams::OutputStream::Ptr<byte>

very rough - going to need more stuff

Definition at line 30 of file FileOutputStream.h.

Enumeration Type Documentation

◆ FlushFlag

enum class Stroika::Foundation::IO::FileSystem ::FileOutputStream::FlushFlag
strong

This flag is used to configure if BinaryOutputStream::Flush will invoke the OS fsync() function to force data to disk (by default Flush just forces the data out of this object to the next object, for files, the operating system).

Note
Design note: It was explicitly chosen to not use enum class here for brevity sake, since this names are already well scoped.

Definition at line 40 of file FileOutputStream.h.

◆ AppendFlag

enum class Stroika::Foundation::IO::FileSystem ::FileOutputStream::AppendFlag
strong

Default AppendFlag is eStartFromStart (truncation), not eAppend

Definition at line 54 of file FileOutputStream.h.

Function Documentation

◆ New()

Ptr Stroika::Foundation::IO::FileSystem ::FileOutputStream::New ( const filesystem::path &  fileName,
FlushFlag  flushFlag = FlushFlag::eDEFAULT 
)

The constructor overload with FileDescriptorType does an 'attach' - taking ownership (and thus later closing) the argument file descriptor (depending on AdoptFDPolicy).

Precondition
fd is a valid file descriptor (for that overload)
Note
We considered having a GetFD () method to retrieve the file descriptor, but that opened up too many possibilities for bugs (like changing the blocking nature of the IO). If you wish - you can always open the file descriptor yourself, track it yourself, and do what you will to it and pass it in, but then the results are 'on you.
The overloads taking no BufferFlag produce a non-buffered stream.
Example Usage
IO::FileSystem::FileOutputStream::New ("/tmp/foo").Write (Memory::BLOB {0x3});
Example Usage
filesystem::path fileName = IO::FileSystem::WellKnownLocations::GetTemporary () / "t.txt";
JSON::Writer{}.Write (v, IO::FileSystem::FileOutputStream::New (fileName));
Example Usage
TextToBinary::Writer::Ptr tw { TextToBinary::Writer::New (IO::FileSystem::FileOutputStream::New ("/tmp/fred.txt")) };
tw.PrintF (L"Hello %s\n", L"World");
Example Usage
Ptr<byte> stdoutStream = FileOutputStream::New (1, FileStream::AdoptFDPolicy::eDisconnectOnDestruction);
Note
Thread-Safety C++-Standard-Thread-Safety-For-Envelope-Plus-Must-Externally-Synchronize-Letter