forked from andreasbuhr/cppcoro
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwrite_only_file.hpp
More file actions
67 lines (59 loc) · 2.01 KB
/
Copy pathwrite_only_file.hpp
File metadata and controls
67 lines (59 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) Lewis Baker
// Licenced under MIT license. See LICENSE.txt for details.
///////////////////////////////////////////////////////////////////////////////
#ifndef CPPCORO_WRITE_ONLY_FILE_HPP_INCLUDED
#define CPPCORO_WRITE_ONLY_FILE_HPP_INCLUDED
#include <cppcoro/writable_file.hpp>
#include <cppcoro/file_share_mode.hpp>
#include <cppcoro/file_buffering_mode.hpp>
#include <cppcoro/file_open_mode.hpp>
#include <cppcoro/filesystem.hpp>
namespace cppcoro
{
class write_only_file : public writable_file
{
public:
/// Open a file for write-only access.
///
/// \param ioContext
/// The I/O context to use when dispatching I/O completion events.
/// When asynchronous write operations on this file complete the
/// completion events will be dispatched to an I/O thread associated
/// with the I/O context.
///
/// \param pathMode
/// Path of the file to open.
///
/// \param openMode
/// Specifies how the file should be opened and how to handle cases
/// when the file exists or doesn't exist.
///
/// \param shareMode
/// Specifies the access to be allowed on the file concurrently with this file access.
///
/// \param bufferingMode
/// Specifies the modes/hints to provide to the OS that affects the behaviour
/// of its file buffering.
///
/// \return
/// An object that can be used to write to the file.
///
/// \throw std::system_error
/// If the file could not be opened for write.
[[nodiscard]]
static write_only_file open(
io_service& ioService,
const cppcoro::filesystem::path& path,
file_open_mode openMode = file_open_mode::create_or_open,
file_share_mode shareMode = file_share_mode::none,
file_buffering_mode bufferingMode = file_buffering_mode::default_);
protected:
#if CPPCORO_OS_WINNT
write_only_file(detail::win32::safe_handle&& fileHandle) noexcept;
#elif CPPCORO_OS_LINUX
write_only_file(detail::linux::safe_file_data&& fileData) noexcept;
#endif
};
}
#endif