use std::fs::File;
use std::path::Path;
use log::warn;
use crate::Extent;
use crate::common::{copy_bytes_uspace, copy_range_uspace};
use crate::errors::{Result, Error};
pub fn copy_file_bytes(infd: &File, outfd: &File, bytes: u64) -> Result<usize> {
copy_bytes_uspace(infd, outfd, bytes as usize)
}
pub fn copy_file_offset(infd: &File, outfd: &File, bytes: u64, off: i64) -> Result<usize> {
copy_range_uspace(infd, outfd, bytes as usize, off as usize)
}
pub fn probably_sparse(_fd: &File) -> Result<bool> {
Ok(false)
}
pub fn map_extents(_fd: &File) -> Result<Option<Vec<Extent>>> {
Ok(None)
}
pub fn next_sparse_segments(_infd: &File, _outfd: &File, _pos: u64) -> Result<(u64, u64)> {
Err(Error::UnsupportedOperation {})
}
pub fn copy_sparse(infd: &File, outfd: &File) -> Result<u64> {
let len = infd.metadata()?.len();
copy_file_bytes(&infd, &outfd, len)
.map(|i| i as u64)
}
pub fn copy_node(src: &Path, _dest: &Path) -> Result<()> {
warn!("Socket copy not supported by this OS: {}", src.to_string_lossy());
Ok(())
}
pub fn reflink(_infd: &File, _outfd: &File) -> Result<bool> {
Ok(false)
}