Sha256: 3117b349ddcbc554757e0713bb8ace3423f78adc8ebee30dee50567372ff3d96

Contents?: true

Size: 1.05 KB

Versions: 36

Compression:

Stored size: 1.05 KB

Contents

use super::{internal_open, read_link_one};
use crate::fs::{open_unchecked, FollowSymlinks, MaybeOwnedFile, OpenOptions, OpenUncheckedError};
use std::ffi::OsStr;
use std::path::PathBuf;
use std::{fs, io};

pub(crate) fn open_entry(
    start: &fs::File,
    path: &OsStr,
    options: &OpenOptions,
) -> io::Result<fs::File> {
    match open_unchecked(
        start,
        path.as_ref(),
        options.clone().follow(FollowSymlinks::No),
    ) {
        Ok(file) => Ok(file),
        Err(OpenUncheckedError::Symlink(_, _)) if options.follow == FollowSymlinks::Yes => {
            let mut symlink_count = 0;
            let destination = read_link_one(start, path, &mut symlink_count, PathBuf::new())?;
            let maybe = MaybeOwnedFile::borrowed(start);
            internal_open(maybe, &destination, options, &mut symlink_count, None)
                .map(MaybeOwnedFile::unwrap_owned)
        }
        Err(OpenUncheckedError::NotFound(err))
        | Err(OpenUncheckedError::Other(err))
        | Err(OpenUncheckedError::Symlink(err, _)) => Err(err),
    }
}

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
wasmtime-14.0.0 ./ext/cargo-vendor/cap-primitives-2.0.0/src/fs/manually/open_entry.rs
wasmtime-13.0.0 ./ext/cargo-vendor/cap-primitives-2.0.0/src/fs/manually/open_entry.rs
wasmtime-12.0.1 ./ext/cargo-vendor/cap-primitives-2.0.0/src/fs/manually/open_entry.rs
wasmtime-12.0.0 ./ext/cargo-vendor/cap-primitives-2.0.0/src/fs/manually/open_entry.rs
wasmtime-11.0.0 ./ext/cargo-vendor/cap-primitives-1.0.15/src/fs/manually/open_entry.rs
wasmtime-10.0.1 ./ext/cargo-vendor/cap-primitives-1.0.15/src/fs/manually/open_entry.rs
wasmtime-10.0.0 ./ext/cargo-vendor/cap-primitives-1.0.15/src/fs/manually/open_entry.rs
wasmtime-9.0.4 ./ext/cargo-vendor/cap-primitives-1.0.15/src/fs/manually/open_entry.rs
wasmtime-9.0.1 ./ext/cargo-vendor/cap-primitives-1.0.15/src/fs/manually/open_entry.rs
wasmtime-8.0.0 ./ext/cargo-vendor/cap-primitives-1.0.14/src/fs/manually/open_entry.rs
wasmtime-7.0.0 ./ext/cargo-vendor/cap-primitives-1.0.9/src/fs/manually/open_entry.rs
wasmtime-6.0.1 ./ext/cargo-vendor/cap-primitives-1.0.5/src/fs/manually/open_entry.rs
wasmtime-6.0.0 ./ext/cargo-vendor/cap-primitives-1.0.5/src/fs/manually/open_entry.rs
wasmtime-5.0.0 ./ext/cargo-vendor/cap-primitives-1.0.4/src/fs/manually/open_entry.rs
wasmtime-0.4.1 ./ext/cargo-vendor/cap-primitives-1.0.3/src/fs/manually/open_entry.rs
wasmtime-0.4.0 ./ext/cargo-vendor/cap-primitives-1.0.2/src/fs/manually/open_entry.rs