Commit Graph

12 Commits

Author SHA1 Message Date
David CARLIER
2ab5558e08
fix, mostly, solaris build. (#2248)
With few exceptions as newer interfaces like preadv/pwritev unsupported
only on solaris.
2023-12-08 19:29:11 +00:00
Alex Saveau
58f99947bf
Run a round of clippy to fix CI
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2022-11-06 11:40:46 -08:00
SteveLauC
d458ecd4e1 remove deprecated items 2022-08-09 12:15:52 +08:00
Costin-Robert Sin
3e6cb639f0 Fix all formating problems to pass CI formating test
Signed-off-by: Costin-Robert Sin <sin.costinrobert@gmail.com>
2022-06-24 00:35:52 +03:00
Al Hoang
d02e27476c add haiku support
* enabled as much functionality and defines that match
  updated libc definitions for haiku
2022-05-14 18:45:18 -05:00
Alan Somers
a09b1c8ac6 Clippy cleanup
And this time, start running Clippy in CI
2021-09-19 07:58:15 -06:00
Alan Somers
2d796eba38 Collapse Error into Errno
Now that Nix's weird error types are eliminated, there's no reason not
to simply use Errno as the Error type.
2021-07-07 20:49:29 -06:00
Alan Somers
6511d02414 Overhaul Nix's error types
For many of Nix's consumers it be convenient to easily convert a Nix
error into a std::io::Error.  That's currently not possible because of
the InvalidPath, InvalidUtf8, and UnsupportedOperation types that have
no equivalent in std::io::Error.

However, very few of Nix's public APIs actually return those unusual
errors.  So a more useful API would be for Nix's standard error type to
implement Into<std::io::Error>.

This commit makes Error a simple NewType around Errno.  For most
functions it's a drop-in replacement.  There are only three exceptions:

* clearenv now returns a bespoke error type.  It was the only Nix
  function whose error couldn't be cleanly mapped onto an Errno.

* sys::signal::signal now returns Error(Errno::ENOTSUP) instead of
  Error::UnsupportedOperation when the user passes an incompatible
  argument to `handler`.

* When a NixPath exceeds PATH_MAX, it will now return
  Error(Errno::ENAMETOOLONG) instead of Error::InvalidPath.

In the latter two cases there is now some abiguity about whether the
error code was generated by Nix or by the OS.  But I think the ambiguity
is worth it for the sake of being able to implement Into<io::Error>.

This commit also introduces Error::Sys() as a migration aid.  Previously
that as an enum variant.  Now it's a function, but it will work in many
of the same contexts as the original.

Fixes #1155
2021-07-07 20:49:28 -06:00
Jason King
d444f1bcf2 illumos and Solaris support
Co-authored-by: Dominik Hassler <hadfl@omnios.org>
Co-authored-by: Joshua M. Clulow <josh@sysmgr.org>
2021-03-21 23:04:03 +00:00
William Manley
91c2a080ea Dir: Implement IntoIterator for Dir
This is useful to allow returning an iterator based on a directory iterator
without needing a self-referential struct.
2021-02-15 13:48:17 +00:00
Alan Somers
1ae5dd8b16 Convert the crate to edition 2018 2020-05-31 19:07:15 -06:00
Scott Lamb
f9ebcb7c00 new dir module
This is a lower-level interface than `std::fs::ReadDir`. Notable differences:

   * can be opened from a file descriptor (as returned by `openat`, perhaps
     before knowing if the path represents a file or directory). Uses
     `fdopendir` for this, available on all Unix platforms as of
     rust-lang/libc#1018.

   * implements `AsRawFd`, so it can be passed to `fstat`, `openat`, etc.

   * can be iterated through multiple times without closing and reopening the
     file descriptor. Each iteration rewinds when finished.

   * returns entries for `.` (current directory) and `..` (parent directory).

   * returns entries' names as a `CStr` (no allocation or conversion beyond
     whatever libc does).
2018-09-03 17:04:57 -07:00