History

Add remaining docs to get `gix-fs` into 'early' mode.

Sebastian Thiel committed 3 years ago

Commit 5783df21 parent 3456c843 files · +13 −2Browse files

Unified · Split

3 files
  1. README.md +1 −1
  2. gix-fs/src/lib.rs +2 −1
  3. gix-fs/src/symlink.rs +10 −0
README.md+1−1
@@ -83,10 +83,10 @@ is usable to some extent. · 82 unmodified lines
8383 * [gix-command](https://github.com/Byron/gitoxide/blob/main/crate-status.md#gix-command)
8484 * [gix-prompt](https://github.com/Byron/gitoxide/blob/main/crate-status.md#gix-prompt)
8585 * [gix-refspec](https://github.com/Byron/gitoxide/blob/main/crate-status.md#gix-refspec)
86+ * [gix-fs](https://github.com/Byron/gitoxide/blob/main/crate-status.md#gix-fs)
8687 * `gitoxide-core`
8788 * **very early** _(possibly without any documentation and many rough edges)_
8889 * [gix-utils](https://github.com/Byron/gitoxide/blob/main/crate-status.md#gix-utils)
89− * [gix-fs](https://github.com/Byron/gitoxide/blob/main/crate-status.md#gix-fs)
9090 * [gix-worktree](https://github.com/Byron/gitoxide/blob/main/crate-status.md#gix-worktree)
9191 * [gix-bitmap](https://github.com/Byron/gitoxide/blob/main/crate-status.md#gix-bitmap)
9292 * [gix-date](https://github.com/Byron/gitoxide/blob/main/crate-status.md#gix-date)
gix-fs/src/lib.rs+2−1
@@ -1,5 +1,5 @@
11 //! A crate with file-system specific utilities.
2−#![deny(rust_2018_idioms)]
2+#![deny(rust_2018_idioms, missing_docs)]
33 #![forbid(unsafe_code)]
44
55 /// Common knowledge about the worktree that is needed across most interactions with the work tree
@@ -51,4 +51,5 @@ pub struct Stack { · 45 unmodified lines
5151 current_is_directory: bool,
5252 }
5353
54+///
5455 pub mod stack;
gix-fs/src/symlink.rs+10−0
@@ -1,16 +1,21 @@
11 use std::{io, io::ErrorKind::AlreadyExists, path::Path};
22
33 #[cfg(not(windows))]
4+/// Create a new symlink at `link` which points to `original`.
45 pub fn create(original: &Path, link: &Path) -> io::Result<()> {
56 std::os::unix::fs::symlink(original, link)
67 }
78
89 #[cfg(not(windows))]
10+/// Remove a symlink.
11+///
12+/// Note that on only on windows this is special.
913 pub fn remove(path: &Path) -> io::Result<()> {
1014 std::fs::remove_file(path)
1115 }
1216
1317 // TODO: use the `symlink` crate once it can delete directory symlinks
18+/// Remove a symlink.
1419 #[cfg(windows)]
1520 pub fn remove(path: &Path) -> io::Result<()> {
1621 if let Ok(meta) = std::fs::metadata(path) {
@@ -25,6 +30,7 @@ pub fn remove(path: &Path) -> io::Result<()> { · 8 unmodified lines
2530 }
2631
2732 #[cfg(windows)]
33+/// Create a new symlink at `link` which points to `original`.
2834 pub fn create(original: &Path, link: &Path) -> io::Result<()> {
2935 use std::os::windows::fs::{symlink_dir, symlink_file};
3036 // TODO: figure out if links to links count as files or whatever they point at
@@ -36,6 +42,8 @@ pub fn create(original: &Path, link: &Path) -> io::Result<()> { · 5 unmodified lines
3642 }
3743
3844 #[cfg(not(windows))]
45+/// Return true if `err` indicates that a file collision happened, i.e. a symlink couldn't be created as the `link`
46+/// already exists as filesystem object.
3947 pub fn is_collision_error(err: &std::io::Error) -> bool {
4048 // TODO: use ::IsDirectory as well when stabilized instead of raw_os_error(), and ::FileSystemLoop respectively
4149 err.kind() == AlreadyExists
@@ -45,6 +53,8 @@ pub fn is_collision_error(err: &std::io::Error) -> bool { · 3 unmodified lines
4553 }
4654
4755 #[cfg(windows)]
56+/// Return true if `err` indicates that a file collision happened, i.e. a symlink couldn't be created as the `link`
57+/// already exists as filesystem object.
4858 pub fn is_collision_error(err: &std::io::Error) -> bool {
4959 err.kind() == AlreadyExists || err.kind() == std::io::ErrorKind::PermissionDenied
5060 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t