add unistd::getcwd and unistd::mkdir As a (late) followup of [this withdrawn PR](https://github.com/rust-lang/libc/pull/326) I have added getcwd (wrapper around `libc::getcwd`) and mkdir (wrapper around `libc::mkdir`) and added testing. A few notes: - I'm new to rust so I would appreciate some pair of eyes testing the code, plus I'm open for revision of code or general remarks about my coding style - I have run the tests both on OSX as on Linux (Ubuntu) - I've run `clippy` to see if my code is well formatted, however clippy issues many warnings about the project. I think I didn't add any more warnings - the methods in unistd are not documented so I also left out the documentation of `getcwd` and `mkdir`, although I think it'd probably be good to add some documentation, especially some example code how to use the methods - the base idea of `getcwd` is [taken from std](https://github.com/rust-lang/rust/blob/1.9.0/src/libstd/sys/unix/os.rs#L95-L119), should I mention that somewhere? |
||
|---|---|---|
| ci | ||
| nix-test | ||
| src | ||
| test | ||
| .gitignore | ||
| .travis.yml | ||
| build.rs | ||
| Cargo.toml | ||
| CHANGELOG.md | ||
| CONTRIBUTING.md | ||
| CONVENTIONS.md | ||
| deploy.sh | ||
| LICENSE | ||
| README.md | ||
| RELEASE_PROCEDURE.md | ||
Rust bindings to *nix APIs
Nix seeks to provide friendly bindings to various *nix platform APIs (Linux, Darwin, ...). The goal is to not provide a 100% unified interface, but to unify what can be while still providing platform specific APIs.
For many system APIs, Nix provides a safe alternative to the unsafe APIs exposed by the libc crate. This is done by wrapping the libc functionality with types/abstractions that enforce legal/safe usage.
As an example of what Nix provides, examine the differences between what is exposed by libc and nix for the gethostname system call:
// libc api (unsafe, requires handling return code/errno)
pub unsafe extern fn gethostname(name: *mut c_char, len: size_t) -> c_int;
// nix api (returns a nix::Result)
pub fn gethostname(name: &mut [u8]) -> Result<()>;
Usage
To use nix, first add this to your Cargo.toml:
[dependencies]
nix = "0.6.0"
Then, add this to your crate root:
extern crate nix;
Contributing
Contributions are very welcome. Please See CONTRIBUTING for additional details.
License
Nix is licensed under the MIT license. See LICENSE for more details.