* Initial commit of io2 module
* Rename to io2.
Add createPath with permissions.
Add writeFile with permissions.
Add tests.
* Add test_io2 to all tests.
* Add posix permissions.
* Add toString procedure for set[Permission] and tests.
* Remove safeio.nim
* Add setPermissions procedures.
Fix writeFile() to change permissions.
Add more writeFile() tests.
* Change C ReadOnly/WriteOnly/ReadWrite to pair of Read/Write.
Add tests for openFile.
* File handles is no inherited by default, with option to turn on inheritance.
* Review comments fixes.
More tests.
* Fix x86 compilation problems.
* Rename toSet -> toPermissions.
* Avoid race condition on writeFile permissions.
This code is extracted from the error-handling proposal where it's
used to implement `Try` blocks (Faux closures are created there in
order to assign raises lists to them). The desktop team faced a
similar problem where the `spawn` API doesn't support closures,
but the restriction can be easily worked-around with faux closures.
Without lifetime tracking, ranges pose a number of issues with regards
to memory safety - use openArray instead which is limited but safe.
In its present form, ranges take a copy of whatever is passed to them
which obscures the copies that they take, leading to misleading and slow
code.
If openArray is not applicable, simply do a seq copy - it's fine and
really doesn't matter in 95% of all cases, then profile and use other
techniques where needed.
It turned out that Nim's Option type is broken for `not nil` and
`requiresInit` types. It will report an udesired warning due to
the way `none` is defined. The `Result` type doesn't suffer from
this problem, so I've transitioned some APIs in NBC to use the
new `results.Opt[T]` type (alias of `Result[T, void]`).
Perhaps we should renamed `Result` to `Res` to make the naming
more consistent and to allow the code to more easily fit in the
80 character per-line budget.