aboutsummaryrefslogtreecommitdiff
path: root/include/cru/common/io/OpenFileFlag.h
blob: fd8b6e2cea80f143a44c1ef608a44e15d609b02d (plain)
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
#pragma once

#include "../Bitmask.h"

namespace cru::io {
namespace details {
struct OpenFileFlagTag {};
}  // namespace details
using OpenFileFlag = Bitmask<details::OpenFileFlagTag>;

struct OpenFileFlags {
  /**
   * \brief for reading
   */
  static constexpr OpenFileFlag Read{0x1};

  /**
   * \brief for writing
   */
  static constexpr OpenFileFlag Write{0x2};

  /**
   * \brief when writing, seek to end first
   * Only effective for writing.
   */
  static constexpr OpenFileFlag Append{0x4};

  /**
   * \brief when writing, truncate the file to empty
   * Only effective for writing.
   * So the content is erased! Be careful!
   */
  static constexpr OpenFileFlag Truncate{0x8};

  /**
   * \brief when writing, if the file does not exist, create one
   * Only effective for writing.
   */
  static constexpr OpenFileFlag Create{0x10};

  /**
   *  TODO: ???
   */
  static constexpr OpenFileFlag Exclusive{0x20};
};
}  // namespace cru::io