MCPcopy Create free account
hub / github.com/Effect-TS/effect / openFlagBits

Function openFlagBits

packages/platform/node-shared/src/NodeFileSystem.ts:223–247  ·  view source on GitHub ↗
(flag: FileSystem.OpenFlag)

Source from the content-addressed store, hash-verified

221// == open
222
223const openFlagBits = (flag: FileSystem.OpenFlag): number => {
224 const { O_APPEND, O_CREAT, O_EXCL, O_RDONLY, O_RDWR, O_TRUNC, O_WRONLY } = NFS.constants
225 switch (flag) {
226 case "r":
227 return O_RDONLY
228 case "r+":
229 return O_RDWR
230 case "w":
231 return O_TRUNC | O_CREAT | O_WRONLY
232 case "wx":
233 return O_TRUNC | O_CREAT | O_WRONLY | O_EXCL
234 case "w+":
235 return O_TRUNC | O_CREAT | O_RDWR
236 case "wx+":
237 return O_TRUNC | O_CREAT | O_RDWR | O_EXCL
238 case "a":
239 return O_APPEND | O_CREAT | O_WRONLY
240 case "ax":
241 return O_APPEND | O_CREAT | O_WRONLY | O_EXCL
242 case "a+":
243 return O_APPEND | O_CREAT | O_RDWR
244 case "ax+":
245 return O_APPEND | O_CREAT | O_RDWR | O_EXCL
246 }
247}
248
249// Reject unsupported platforms: libuv silently ignores unknown flags on Windows.
250const noFollowFlags = (method: string, flag: FileSystem.OpenFlag) =>

Callers 1

noFollowFlagsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected