repo: Expose dfd_as_file()

The `dfd()` API returns just an integer.  Add a safe API that
makes a copy of the fd.  What we really want here is `BorrowedFd` from
https://github.com/rust-lang/rfcs/blob/master/text/3128-io-safety.md
but that isn't here yet.
This commit is contained in:
Colin Walters committed 2022-05-06 12:53:57 -04:00
1 parent e33767cc2a
commit 955f0ddb9d
2 files changed
+28

No files matched your search

+11
View File
@@ -106,6 +106,17 @@ fn should_write_content_to_repo() {
}
}
#[test]
#[cfg(feature = "v2016_4")]
fn repo_file() {
use std::os::unix::fs::MetadataExt;
let test_repo = TestRepo::new();
let m1 = test_repo.repo.dfd_as_file().unwrap().metadata().unwrap();
let m2 = test_repo.repo.dfd_as_file().unwrap().metadata().unwrap();
assert_eq!(m1.dev(), m2.dev());
assert_eq!(m1.ino(), m2.ino());
}
fn copy_file(src: &TestRepo, dest: &TestRepo, obj: &ObjectName) {
let (stream, len) = src
.repo