Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
FStreamSupport.h
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#ifndef _Stroika_Foundation_Streams_iostream_FStreamSupport_h_
5#define _Stroika_Foundation_Streams_iostream_FStreamSupport_h_ 1
6
7#include "Stroika/Foundation/StroikaPreComp.h"
8
9#include <filesystem>
10#include <fstream>
11
13#include "Stroika/Foundation/IO/FileSystem/Common.h"
14
16
17 using Characters::String;
18
19 /*
20 * OpenInputFileStream () is like the ifstream::open CTOR - but throws FILE exceptions on failure.
21 *
22 * There is no need to include ios_base::in among the open-modes as this is included automatically.
23 *
24 * A very common thing to include would be ios_base::binary (DEFAULT ON), if you want to assure no CR/LF transformations done, or pass '0'
25 * to remove the 'ios_base::binary' default.
26 *
27 * \note This calls https://en.cppreference.com/w/cpp/io/basic_ios/exceptions to force any future failed operations to throw (including open)
28 *
29 */
30 ifstream& OpenInputFileStream (ifstream* ifStream, const filesystem::path& fileName, ios_base::openmode _Mode = ios_base::binary);
31 ifstream& OpenInputFileStream (ifstream& tmpIFStream, const filesystem::path& fileName, ios_base::openmode _Mode = ios_base::binary);
32
33 /*
34 * OpenOutputFileStream () is like the ofstream::open CTOR - but throws FILE exceptions on failure.
35 *
36 * There is no need to include ios_base::out among the open-modes as this is included automatically.
37 *
38 * A very common thing to include would be ios_base::binary (DEFAULT ON), if you want to assure no CR/LF transformations done.
39 *
40 * Another very common thing to include would be ios_base::trunc (DEFAULT ON).
41 *
42 * \note This calls https://en.cppreference.com/w/cpp/io/basic_ios/exceptions to force any future failed operations to throw (including open)
43 *
44 */
45 ofstream& OpenOutputFileStream (ofstream* ofStream, const filesystem::path& fileName, ios_base::openmode _Mode = ios_base::trunc | ios_base::binary);
46 ofstream& OpenOutputFileStream (ofstream& tmpOfStream, const filesystem::path& fileName,
47 ios_base::openmode _Mode = ios_base::trunc | ios_base::binary);
48
49}
50
51#endif /*_Stroika_Foundation_Streams_iostream_FStreamSupport_h_*/