1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT license.
3
4#pragma once
5
6#include <ostream>
7
8#include "../core/async.h"
9#include "../core/lss_allocator.h"
10
11using namespace FASTER::core;
12
13namespace FASTER {
14namespace environment {
15
16enum class FileCreateDisposition : uint8_t {
17 /// Creates the file if it does not exist; truncates it if it does.
18 CreateOrTruncate,
19 /// Opens the file if it exists; creates it if it does not.
20 OpenOrCreate,
21 /// Opens the file if it exists.
22 OpenExisting
23};
24
25inline std::ostream& operator<<(std::ostream& os, FileCreateDisposition val) {
26 switch(val) {
27 case FileCreateDisposition::CreateOrTruncate:
28 os << "CreateOrTruncate";
29 break;
30 case FileCreateDisposition::OpenOrCreate:
31 os << "OpenOrCreate";
32 break;
33 case FileCreateDisposition::OpenExisting:
34 os << "OpenExisting";
35 break;
36 default:
37 os << "UNKNOWN: " << static_cast<uint8_t>(val);
38 break;
39 }
40 return os;
41}
42
43enum class FileOperationType : uint8_t { Read, Write };
44
45struct FileOptions {
46 FileOptions()
47 : unbuffered{ false }
48 , delete_on_close{ false } {
49 }
50 FileOptions(bool unbuffered_, bool delete_on_close_)
51 : unbuffered{ unbuffered_ }
52 , delete_on_close{ delete_on_close_ } {
53 }
54
55 bool unbuffered;
56 bool delete_on_close;
57};
58
59}
60} // namespace FASTER::environment