1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use super::open_parent;
use crate::fs::{hard_link_unchecked, MaybeOwnedFile};
use std::path::Path;
use std::{fs, io};
pub(crate) fn hard_link(
old_start: &fs::File,
old_path: &Path,
new_start: &fs::File,
new_path: &Path,
) -> io::Result<()> {
let old_start = MaybeOwnedFile::borrowed(old_start);
let new_start = MaybeOwnedFile::borrowed(new_start);
let (old_dir, old_basename) = open_parent(old_start, old_path)?;
let (new_dir, new_basename) = open_parent(new_start, new_path)?;
hard_link_unchecked(
&old_dir,
old_basename.as_ref(),
&new_dir,
new_basename.as_ref(),
)
}