Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
FileInputStream.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/Common.h"
#include "Stroika/Foundation/IO/FileSystem/FileStream.h"
#include "Stroika/Foundation/Streams/InputStream.h"
#include "FileInputStream.inl"

Go to the source code of this file.

Namespaces

namespace  Stroika::Foundation
 
namespace  Stroika::Foundation::IO::FileSystem
 

Typedefs

using Stroika::Foundation::IO::FileSystem::FileInputStream::Ptr = Streams::InputStream::Ptr< byte >
 

Enumerations

enum class  Stroika::Foundation::IO::FileSystem::FileInputStream::BufferFlag
 

Functions

Ptr Stroika::Foundation::IO::FileSystem::FileInputStream::New (const filesystem::path &fileName, SeekableFlag seekable=kSeekableFlag_DEFAULT)
 

Variables

constexpr BufferFlag Stroika::Foundation::IO::FileSystem::FileInputStream::kBufferFlag_DEFAULT = eUnbuffered
 
constexpr SeekableFlag Stroika::Foundation::IO::FileSystem::FileInputStream::kSeekableFlag_DEFAULT = SeekableFlag::eSeekable
 

Detailed Description

Note
Code-Status: Beta

TODO:

Definition in file FileInputStream.h.

Typedef Documentation

◆ Ptr

using Stroika::Foundation::IO::FileSystem::FileInputStream::Ptr = typedef Streams::InputStream::Ptr<byte>

very rough - going to need more stuff

Definition at line 35 of file FileInputStream.h.

Enumeration Type Documentation

◆ BufferFlag

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.

Definition at line 47 of file FileInputStream.h.

Function Documentation

◆ New()

auto Stroika::Foundation::IO::FileSystem::FileInputStream::New ( const filesystem::path &  fileName,
SeekableFlag  seekable = kSeekableFlag_DEFAULT 
)

The static New method is like a constructor, but it constructs a smart pointer of some appropriate subtype defined by its parameters.

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

Precondition
fd is a valid file descriptor (for that overload)
Example Usage
static const filesystem::path kProcCPUInfoFileName_{"/proc/cpuinfo"sv};
Ptr stream = FileInputStream::New (kProcCPUInfoFileName_, FileInputStream::eNotSeekable);
Example Usage
Ptr stdinStream = FileInputStream::New (0, AdoptFDPolicy::eDisconnectOnDestruction);
Note
Thread-Safety C++-Standard-Thread-Safety-For-Envelope-Plus-Must-Externally-Synchronize-Letter

Definition at line 281 of file FileInputStream.cpp.

Variable Documentation

◆ kBufferFlag_DEFAULT

constexpr BufferFlag Stroika::Foundation::IO::FileSystem::FileInputStream::kBufferFlag_DEFAULT = eUnbuffered
constexpr
Note
FileInputStream::kBufferFlag_DEFAULT defaults to eUnbuffered, because StreamReader generally provides a better buffering strategy.

Definition at line 66 of file FileInputStream.h.

◆ kSeekableFlag_DEFAULT

constexpr SeekableFlag Stroika::Foundation::IO::FileSystem::FileInputStream::kSeekableFlag_DEFAULT = SeekableFlag::eSeekable
constexpr
Note
- prior to v2.1d27, this defaulted to unseekable, but for files, it makes way more sense to default to seekable, since doing so typically costs nothing, and is pretty commonly useful.

Definition at line 72 of file FileInputStream.h.