cap-primitives 0.13.3

Capability-oriented primitives
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use crate::{
    fs::{open_unchecked, OpenOptions},
    posish::fs::file_path,
};
use posish::fs::cwd;
use std::{fs, io};

/// Implementation of `reopen`.
pub(crate) fn reopen_impl(file: &fs::File, options: &OpenOptions) -> io::Result<fs::File> {
    if let Some(path) = file_path(file) {
        Ok(open_unchecked(&cwd(), &path, options)?)
    } else {
        Err(io::Error::new(io::ErrorKind::Other, "Couldn't reopen file"))
    }
}