8cf10ce184
- Adds file, readable_file, writable_file, read_only_file, write_only_file and read_write_file classes. - Adds file_share_mode, file_open_mode, file_buffering_mode enums. - Supports async read/write but only synchronous open for now. - Removes support for VS 2015 since implementation makes use of std::optional which is only available in VS 2017.
45 lines
1.3 KiB
C++
45 lines
1.3 KiB
C++
///////////////////////////////////////////////////////////////////////////////
|
|
// Copyright (c) Lewis Baker
|
|
// Licenced under MIT license. See LICENSE.txt for details.
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
#ifndef CPPCORO_FILE_SHARE_MODE_HPP_INCLUDED
|
|
#define CPPCORO_FILE_SHARE_MODE_HPP_INCLUDED
|
|
|
|
namespace cppcoro
|
|
{
|
|
enum class file_share_mode
|
|
{
|
|
/// Don't allow any other processes to open the file concurrently.
|
|
none = 0,
|
|
|
|
/// Allow other processes to open the file in read-only mode
|
|
/// concurrently with this process opening the file.
|
|
read = 1,
|
|
|
|
/// Allow other processes to open the file in write-only mode
|
|
/// concurrently with this process opening the file.
|
|
write = 2,
|
|
|
|
/// Allow other processes to open the file in read and/or write mode
|
|
/// concurrently with this process opening the file.
|
|
read_write = read | write,
|
|
|
|
/// Allow other processes to delete the file while this process
|
|
/// has the file open.
|
|
delete_ = 4
|
|
};
|
|
|
|
constexpr file_share_mode operator|(file_share_mode a, file_share_mode b)
|
|
{
|
|
return static_cast<file_share_mode>(
|
|
static_cast<int>(a) | static_cast<int>(b));
|
|
}
|
|
|
|
constexpr file_share_mode operator&(file_share_mode a, file_share_mode b)
|
|
{
|
|
return static_cast<file_share_mode>(
|
|
static_cast<int>(a) & static_cast<int>(b));
|
|
}
|
|
}
|
|
|
|
#endif
|