Silicium
write_file.hpp
Go to the documentation of this file.
1 #ifndef SILICIUM_WRITE_FILE_HPP
2 #define SILICIUM_WRITE_FILE_HPP
3 
4 #include <silicium/open.hpp>
5 #include <silicium/c_string.hpp>
6 #include <silicium/sink/file_sink.hpp>
7 
8 namespace Si
9 {
11  inline boost::system::error_code write_file(native_path_string name, memory_range data)
12  {
13  Si::error_or<Si::file_handle> const file = Si::overwrite_file(name);
14  if (file.is_error())
15  {
16  return file.error();
17  }
18  Si::file_sink sink(file.get().handle);
19  return Si::append(sink, Si::file_sink_element{data});
20  }
21 }
22 
23 #endif
Definition: c_string.hpp:10
native_file_descriptor handle
Definition: file_handle.hpp:12
Definition: absolute_path.hpp:19
Error error() const BOOST_NOEXCEPT
Definition: error_or.hpp:207
Definition: iterator_range.hpp:26
Value & get()
Definition: error_or.hpp:224
Definition: error_or.hpp:48
bool is_error() const BOOST_NOEXCEPT
Definition: error_or.hpp:202
SILICIUM_USE_RESULT boost::system::error_code write_file(native_path_string name, memory_range data)
Definition: write_file.hpp:11
#define SILICIUM_USE_RESULT
Definition: config.hpp:147