userver
C++ Async Framework
Loading...
Searching...
No Matches
read.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/fs/blocking/read.hpp
4
/// @brief functions for synchronous (blocking) file read operations
5
/// @ingroup userver_universal
6
7
#
include
<
userver
/
fs
/
file_info_with_data
.
hpp
>
8
#
include
<
userver
/
fs
/
settings_read_file
.
hpp
>
9
#
include
<
userver
/
utils
/
boost_filesystem_file_status
.
hpp
>
10
#
include
<
userver
/
utils
/
zstring_view
.
hpp
>
11
12
USERVER_NAMESPACE_BEGIN
13
14
/// @brief blocking function and classes to work with filesystem
15
///
16
/// Use these with caution as they block current thread. It is probably OK to
17
/// use them during startup (on component load), but don't use them after server
18
/// start in the main TaskProcessor. Use asynchronous alternatives from `fs`
19
/// namespace instead.
20
namespace
fs::
blocking
{
21
22
/// @brief Reads file contents synchronously
23
/// @param path file to open
24
/// @returns file contents
25
/// @throws std::runtime_error if read fails for any reason (e.g. no such file,
26
/// read error, etc.),
27
std::string
ReadFileContents
(
utils
::
zstring_view
path);
28
29
/// @brief Checks whether the file exists synchronously
30
/// @param path file path to check
31
/// @returns true if file exists, false if file doesn't exist
32
/// @throws std::runtime_error if something goes wrong (e.g. out of file
33
/// descriptors)
34
bool
FileExists
(
utils
::
zstring_view
path);
35
36
/// @brief Get file type returned by stat(2) synchronously.
37
/// @param path file path
38
/// @throws std::runtime_error if something goes wrong
39
boost::filesystem::file_type
GetFileType
(
utils
::
zstring_view
path);
40
41
/// @brief Returns files from recursively traversed directory
42
/// @param path to directory to traverse recursively
43
/// @param flags settings read files
44
/// @returns map with relative to `path` filepaths and file info
45
/// @throws std::runtime_error if read fails for any reason (e.g. no such file,
46
/// read error, etc.),
47
FileInfoWithDataMap
ReadRecursiveFilesInfoWithData
(
utils
::
zstring_view
path, SettingReadFileFlags flags);
48
49
}
// namespace fs::blocking
50
51
USERVER_NAMESPACE_END
userver
fs
blocking
read.hpp
Generated on Tue Jun 30 2026 13:18:08 for userver by
Doxygen
1.13.2