userver: userver/fs/read.hpp Source File
Loading...
Searching...
No Matches
read.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/fs/read.hpp
4/// @brief functions for asynchronous file read operations
5
6#include <string>
7
8#include <userver/engine/task/task_processor_fwd.hpp>
9#include <userver/fs/file_info_with_data.hpp>
10#include <userver/fs/path_utils.hpp>
11#include <userver/fs/settings_read_file.hpp>
12
13USERVER_NAMESPACE_BEGIN
14
15/// @brief filesystem support
16namespace fs {
17
18/// @brief Returns files from recursively traversed directory
19/// @param async_tp TaskProcessor for synchronous waiting
20/// @param path to directory to traverse recursively
21/// @param flags settings read files
22/// @returns map with relative to `path` filepaths and file info
23/// @throws std::runtime_error if read fails for any reason (e.g. no such file,
24/// read error, etc.),
26 engine::TaskProcessor& async_tp,
27 const std::string& path,
28 SettingReadFileFlags flags = {SettingsReadFile::kSkipHidden}
29);
30
31/// @brief Reads file contents asynchronously
32/// @param async_tp TaskProcessor for synchronous waiting
33/// @param path file to open
34/// @returns file contents
35/// @throws std::runtime_error if read fails for any reason (e.g. no such file,
36/// read error, etc.),
37std::string ReadFileContents(engine::TaskProcessor& async_tp, const std::string& path);
38
39/// @brief Checks whether the file exists asynchronously
40/// @param async_tp TaskProcessor for synchronous waiting
41/// @param path file path to check
42/// @returns true if file exists, false if file doesn't exist
43/// @throws std::runtime_error if something goes wrong (e.g. out of file
44/// descriptors)
45bool FileExists(engine::TaskProcessor& async_tp, const std::string& path);
46
47} // namespace fs
48
49USERVER_NAMESPACE_END