Stroika Library
3.0d16
Help-Home
Loading...
Searching...
No Matches
FileStream.h
Go to the documentation of this file.
1
/*
2
* Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3
*/
4
#ifndef _Stroika_Foundation_IO_FileSystem_FileStream_h_
5
#define _Stroika_Foundation_IO_FileSystem_FileStream_h_ 1
6
7
#include "Stroika/Foundation/StroikaPreComp.h"
8
9
#if qStroika_Foundation_Common_Platform_POSIX
10
#include <unistd.h>
11
#endif
12
13
#include "
Stroika/Foundation/Common/Enumeration.h
"
14
15
/**
16
* \file
17
*
18
* \note Code-Status: <a href="Code-Status.md#Beta">Beta</a>
19
*/
20
21
namespace
Stroika::Foundation::IO::FileSystem::FileStream {
22
23
/**
24
* This only applies to File Streams constructed with an argument FileDescriptor. This controls whether the adopted
25
* file descriptor will be automatically closed when the last 'shared' reference to the stream goes out of scope.
26
*
27
* By far the most common answer will be eCloseOnDestruction, but eDisconnectOnDestruction can be helpful
28
* when multiple streams are associated with a given file descriptor (or for predefined descriptors like stdin).
29
*
30
* Intentionally provide no eDEFAULT, since rarely used by file descriptor, and best to be clear when doing so about the
31
* treatment on close.
32
*/
33
enum class
AdoptFDPolicy
{
34
eCloseOnDestruction,
35
eDisconnectOnDestruction,
36
37
Stroika_Define_Enum_Bounds
(eCloseOnDestruction, eDisconnectOnDestruction)
38
};
39
using
AdoptFDPolicy::eCloseOnDestruction;
40
using
AdoptFDPolicy::eDisconnectOnDestruction;
41
42
/**
43
* https://en.wikipedia.org/wiki/File_descriptor
44
*
45
* Integer value Name <unistd.h> symbolic constant[1] <stdio.h> file stream[2]
46
* 0 Standard input STDIN_FILENO stdin
47
* 1 Standard output STDOUT_FILENO stdout
48
* 2 Standard error STDERR_FILENO stderr
49
*/
50
using
FileDescriptorType
= int;
51
52
#if !qStroika_Foundation_Common_Platform_POSIX and !defined(STDIN_FILENO)
53
#define STDIN_FILENO 0
54
#endif
55
#if !qStroika_Foundation_Common_Platform_POSIX and !defined(STDOUT_FILENO)
56
#define STDOUT_FILENO 1
57
#endif
58
#if !qStroika_Foundation_Common_Platform_POSIX and !defined(STDERR_FILENO)
59
#define STDERR_FILENO 2
60
#endif
61
62
}
63
64
/*
65
********************************************************************************
66
***************************** Implementation Details ***************************
67
********************************************************************************
68
*/
69
#include "FileStream.inl"
70
71
#endif
/*_Stroika_Foundation_IO_FileSystem_FileStream_h_*/
Enumeration.h
Stroika_Define_Enum_Bounds
#define Stroika_Define_Enum_Bounds(FIRST_ITEM, LAST_ITEM)
Definition
Enumeration.h:109
Stroika::Foundation::IO::FileSystem::FileStream::AdoptFDPolicy
AdoptFDPolicy
Definition
FileStream.h:33
Stroika::Foundation::IO::FileSystem::FileStream::FileDescriptorType
int FileDescriptorType
Definition
FileStream.h:50
Library
Sources
Stroika
Foundation
IO
FileSystem
FileStream.h
Generated by
1.9.8