| 221 | // == open |
| 222 | |
| 223 | const 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. |
| 250 | const noFollowFlags = (method: string, flag: FileSystem.OpenFlag) => |