0 | module System.UV.Data.File
  1 |
  2 | import Derive.Prelude
  3 |
  4 | %language ElabReflection
  5 | %default total
  6 |
  7 | public export
  8 | data DirentType : Type where
  9 |   DirentUnknown : DirentType
 10 |   DirentFile    : DirentType
 11 |   DirentDir     : DirentType
 12 |   DirentLink    : DirentType
 13 |   DirentFifo    : DirentType
 14 |   DirentSocket  : DirentType
 15 |   DirentChar    : DirentType
 16 |   DirentBlock   : DirentType
 17 |
 18 | %runElab derive "DirentType" [Show,Eq]
 19 |
 20 | public export
 21 | record Flags where
 22 |   constructor MkFlags
 23 |   flags : Bits32
 24 |
 25 | %runElab derive "Flags" [Show,Eq,Ord,Num]
 26 |
 27 | export %inline
 28 | Semigroup Flags where
 29 |   MkFlags x <+> MkFlags y = MkFlags $ prim__or_Bits32 x y
 30 |
 31 | export %inline
 32 | Monoid Flags where
 33 |   neutral = MkFlags 0
 34 |
 35 | public export
 36 | record Mode where
 37 |   constructor MkMode
 38 |   mode : Bits32
 39 |
 40 | %runElab derive "File.Mode" [Show,Eq,Ord,Num]
 41 |
 42 | export %inline
 43 | Semigroup File.Mode where
 44 |   MkMode x <+> MkMode y = MkMode $ prim__or_Bits32 x y
 45 |
 46 | export %inline
 47 | Monoid File.Mode where
 48 |   neutral = MkMode 0
 49 |
 50 | public export
 51 | direntCode : DirentType -> Bits32
 52 | direntCode DirentUnknown = 0
 53 | direntCode DirentFile    = 1
 54 | direntCode DirentDir     = 2
 55 | direntCode DirentLink    = 3
 56 | direntCode DirentFifo    = 4
 57 | direntCode DirentSocket  = 5
 58 | direntCode DirentChar    = 6
 59 | direntCode DirentBlock   = 7
 60 |
 61 | public export
 62 | direntFromCode : Bits32 -> DirentType
 63 | direntFromCode 1 = DirentFile
 64 | direntFromCode 2 = DirentDir
 65 | direntFromCode 3 = DirentLink
 66 | direntFromCode 4 = DirentFifo
 67 | direntFromCode 5 = DirentSocket
 68 | direntFromCode 6 = DirentChar
 69 | direntFromCode 7 = DirentBlock
 70 | direntFromCode _ = DirentUnknown
 71 |
 72 | export %inline
 73 | APPEND : Flags
 74 | APPEND = 1024
 75 |
 76 | export %inline
 77 | CREAT : Flags
 78 | CREAT = 64
 79 |
 80 | export %inline
 81 | DIRECT : Flags
 82 | DIRECT = 16384
 83 |
 84 | export %inline
 85 | DIRECTORY : Flags
 86 | DIRECTORY = 65536
 87 |
 88 | export %inline
 89 | NOATIME : Flags
 90 | NOATIME = 0
 91 |
 92 | export %inline
 93 | NOCTTY : Flags
 94 | NOCTTY = 256
 95 |
 96 | export %inline
 97 | NOFOLLOW : Flags
 98 | NOFOLLOW = 131072
 99 |
100 | export %inline
101 | NONBLOCK : Flags
102 | NONBLOCK = 2048
103 |
104 | export %inline
105 | RANDOM : Flags
106 | RANDOM = 0
107 |
108 | export %inline
109 | RDONLY : Flags
110 | RDONLY = 0
111 |
112 | export %inline
113 | RDWR : Flags
114 | RDWR = 2
115 |
116 | export %inline
117 | SEQUENTIAL : Flags
118 | SEQUENTIAL = 0
119 |
120 | export %inline
121 | SHORT_LIVED : Flags
122 | SHORT_LIVED = 0
123 |
124 | export %inline
125 | SYMLINK : Flags
126 | SYMLINK = 0
127 |
128 | export %inline
129 | SYNC : Flags
130 | SYNC = 1052672
131 |
132 | export %inline
133 | TEMPORARY : Flags
134 | TEMPORARY = 0
135 |
136 | export %inline
137 | TRUNC : Flags
138 | TRUNC = 512
139 |
140 | export %inline
141 | WRONLY : Flags
142 | WRONLY = 1
143 |
144 | export %inline
145 | RWXU : File.Mode
146 | RWXU = 448
147 |
148 | export %inline
149 | RUSR : File.Mode
150 | RUSR = 256
151 |
152 | export %inline
153 | WUSR : File.Mode
154 | WUSR = 128
155 |
156 | export %inline
157 | XUSR : File.Mode
158 | XUSR = 64
159 |
160 | export %inline
161 | RWXG : File.Mode
162 | RWXG = 56
163 |
164 | export %inline
165 | RGRP : File.Mode
166 | RGRP = 32
167 |
168 | export %inline
169 | WGRP : File.Mode
170 | WGRP = 16
171 |
172 | export %inline
173 | XGRP : File.Mode
174 | XGRP = 8
175 |
176 | export %inline
177 | RWXO : File.Mode
178 | RWXO = 7
179 |
180 | export %inline
181 | ROTH : File.Mode
182 | ROTH = 4
183 |
184 | export %inline
185 | WOTH : File.Mode
186 | WOTH = 2
187 |
188 | export %inline
189 | XOTH : File.Mode
190 | XOTH = 1
191 |