0 | -- Note: This module is automatically generated when Idris builds
  1 | -- the library and the constants will be replaced with values
  2 | -- matching the system this is generated on.
  3 | --
  4 | -- The placeholders are here so that it works with tools like the LSP
  5 | -- without first compiling the library. They were generated on an x86_64
  6 | -- GNU/Linux system with GCC. If you are on a similar system, your numbers
  7 | -- might very well be identical.
  8 | module System.Posix.File.Flags
  9 |
 10 | import Data.Bits
 11 | import Data.C.Integer
 12 | import Derive.Prelude
 13 |
 14 | %default total
 15 | %language ElabReflection
 16 | %hide Language.Reflection.TTImp.Mode
 17 |
 18 | public export
 19 | record Flags where
 20 |   constructor F
 21 |   flags : Bits32
 22 |
 23 | %runElab derive "Flags" [Show,Eq,Ord,FromInteger]
 24 |
 25 | public export
 26 | Semigroup Flags where
 27 |   F x <+> F y = F $ x .|. y
 28 |
 29 | public export
 30 | Monoid Flags where neutral = F 0
 31 |
 32 | ||| File permissions.
 33 | public export
 34 | record Mode where
 35 |   constructor M
 36 |   mode : ModeT
 37 |
 38 | namespace Mode
 39 |   %runElab derive "Mode" [Show,Eq,Ord,FromInteger]
 40 |
 41 | public export
 42 | Semigroup Mode where
 43 |   M x <+> M y = M $ x .|. y
 44 |
 45 | public export
 46 | Monoid Mode where neutral = M 0
 47 |
 48 |
 49 | public export
 50 | O_RDONLY : Flags
 51 | O_RDONLY = 0
 52 |
 53 | public export
 54 | O_WRONLY : Flags
 55 | O_WRONLY = 1
 56 |
 57 | public export
 58 | O_RDWR : Flags
 59 | O_RDWR = 2
 60 |
 61 | public export
 62 | O_CLOEXEC : Flags
 63 | O_CLOEXEC = 524288
 64 |
 65 | public export
 66 | O_CREAT : Flags
 67 | O_CREAT = 64
 68 |
 69 | public export
 70 | O_DIRECTORY : Flags
 71 | O_DIRECTORY = 65536
 72 |
 73 | public export
 74 | O_EXCL : Flags
 75 | O_EXCL = 128
 76 |
 77 | public export
 78 | O_NOCTTY : Flags
 79 | O_NOCTTY = 256
 80 |
 81 | public export
 82 | O_NOFOLLOW : Flags
 83 | O_NOFOLLOW = 131072
 84 |
 85 | public export
 86 | O_TRUNC : Flags
 87 | O_TRUNC = 512
 88 |
 89 | public export
 90 | O_APPEND : Flags
 91 | O_APPEND = 1024
 92 |
 93 | public export
 94 | O_ASYNC : Flags
 95 | O_ASYNC = 8192
 96 |
 97 | public export
 98 | O_DSYNC : Flags
 99 | O_DSYNC = 4096
100 |
101 | public export
102 | O_NONBLOCK : Flags
103 | O_NONBLOCK = 2048
104 |
105 | public export
106 | O_SYNC : Flags
107 | O_SYNC = 1052672
108 |
109 | public export
110 | S_IRWXU : Mode
111 | S_IRWXU = 448
112 |
113 | public export
114 | S_IRUSR : Mode
115 | S_IRUSR = 256
116 |
117 | public export
118 | S_IWUSR : Mode
119 | S_IWUSR = 128
120 |
121 | public export
122 | S_IXUSR : Mode
123 | S_IXUSR = 64
124 |
125 | public export
126 | S_IRWXG : Mode
127 | S_IRWXG = 56
128 |
129 | public export
130 | S_IRGRP : Mode
131 | S_IRGRP = 32
132 |
133 | public export
134 | S_IWGRP : Mode
135 | S_IWGRP = 16
136 |
137 | public export
138 | S_IXGRP : Mode
139 | S_IXGRP = 8
140 |
141 | public export
142 | S_IRWXO : Mode
143 | S_IRWXO = 7
144 |
145 | public export
146 | S_IROTH : Mode
147 | S_IROTH = 4
148 |
149 | public export
150 | S_IWOTH : Mode
151 | S_IWOTH = 2
152 |
153 | public export
154 | S_IXOTH : Mode
155 | S_IXOTH = 1
156 |
157 | public export
158 | S_ISUID : Mode
159 | S_ISUID = 2048
160 |
161 | public export
162 | S_ISGID : Mode
163 | S_ISGID = 1024
164 |
165 | public export
166 | S_ISVTX : Mode
167 | S_ISVTX = 512
168 |
169 | ||| Flags for creating a file for output.
170 | export
171 | create : Flags
172 | create = O_WRONLY <+> O_CREAT <+> O_TRUNC
173 |
174 | ||| Flags for creating a file for output.
175 | |||
176 | ||| If the file exists, data is appended to it.
177 | export
178 | append : Flags
179 | append = O_WRONLY <+> O_CREAT <+> O_APPEND
180 |
181 |