userver: userver/fs/blocking/open_mode.hpp Source File
⚠️ This is the documentation for an old userver version. Click here to switch to the latest version.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
open_mode.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/fs/blocking/open_mode.hpp
4/// @brief @copybrief fs::blocking::OpenMode
5/// @ingroup userver_universal
6
7#include <userver/utils/flags.hpp>
8
9USERVER_NAMESPACE_BEGIN
10
11namespace fs::blocking {
12
13enum class OpenFlag {
14 kNone = 0,
15
16 /// Open the file for reading. Reading starts at the beginning of the file.
17 /// At least one of `kRead`, `kWrite` must be set.
18 kRead = 1 << 0,
19
20 /// Open the file for writing. Writing starts at the beginning of the file.
21 /// By default, the file won't be created if it doesn't already exist.
22 /// At least one of `kRead`, `kWrite` must be set.
23 kWrite = 1 << 1,
24
25 /// Used together with `kWrite` to create an empty file and open it
26 /// for writing if it doesn't already exist.
27 kCreateIfNotExists = 1 << 2,
28
29 /// Differs from `kCreateIfNotExists` in that it ensures that the 'open'
30 /// operation creates the file.
31 kExclusiveCreate = 1 << 3,
32
33 /// Used together with `kWrite` to clear the contents of the file in case it
34 /// already exists.
35 kTruncate = 1 << 4,
36
37 /// Used together with `kWrite` to open file for writing to the end of the
38 /// file.
39 kAppend = 1 << 5,
40};
41
42/// A set of OpenFlags
43using OpenMode = utils::Flags<OpenFlag>;
44
45} // namespace fs::blocking
46
47USERVER_NAMESPACE_END