Sha256: 0f3381a047e2fcb8602787980f71acb264a3adff178b81226192b0444f2d0ca2

Contents?: true

Size: 1.57 KB

Versions: 39

Compression:

Stored size: 1.57 KB

Contents

use super::open_parent;
use crate::fs::MaybeOwnedFile;
use std::path::Path;
use std::{fs, io};

/// Implement `symlink` by `open`ing up the parent component of the path and
/// then calling `symlink_unchecked` on the last component.
#[cfg(not(windows))]
pub(crate) fn symlink(old_path: &Path, new_start: &fs::File, new_path: &Path) -> io::Result<()> {
    use crate::fs::symlink_unchecked;
    let new_start = MaybeOwnedFile::borrowed(new_start);

    let (new_dir, new_basename) = open_parent(new_start, new_path)?;

    symlink_unchecked(old_path, &new_dir, new_basename.as_ref())
}

/// Implement `symlink_file` by `open`ing up the parent component of the path
/// and then calling `symlink_file` on the last component.
#[cfg(windows)]
pub(crate) fn symlink_file(
    old_path: &Path,
    new_start: &fs::File,
    new_path: &Path,
) -> io::Result<()> {
    use crate::fs::symlink_file_unchecked;
    let new_start = MaybeOwnedFile::borrowed(new_start);

    let (new_dir, new_basename) = open_parent(new_start, new_path)?;

    symlink_file_unchecked(old_path, &new_dir, new_basename.as_ref())
}

/// Implement `symlink_dir` by `open`ing up the parent component of the path
/// and then calling `symlink_dir` on the last component.
#[cfg(windows)]
pub(crate) fn symlink_dir(
    old_path: &Path,
    new_start: &fs::File,
    new_path: &Path,
) -> io::Result<()> {
    use crate::fs::symlink_dir_unchecked;
    let new_start = MaybeOwnedFile::borrowed(new_start);

    let (new_dir, new_basename) = open_parent(new_start, new_path)?;

    symlink_dir_unchecked(old_path, &new_dir, new_basename.as_ref())
}

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
wasmtime-30.0.2 ./ext/cargo-vendor/cap-primitives-3.4.2/src/fs/via_parent/symlink.rs
wasmtime-29.0.0 ./ext/cargo-vendor/cap-primitives-3.4.2/src/fs/via_parent/symlink.rs
wasmtime-28.0.0 ./ext/cargo-vendor/cap-primitives-3.4.2/src/fs/via_parent/symlink.rs
wasmtime-27.0.0 ./ext/cargo-vendor/cap-primitives-3.4.1/src/fs/via_parent/symlink.rs
wasmtime-26.0.0 ./ext/cargo-vendor/cap-primitives-3.3.0/src/fs/via_parent/symlink.rs
wasmtime-25.0.2 ./ext/cargo-vendor/cap-primitives-3.2.0/src/fs/via_parent/symlink.rs
wasmtime-25.0.1 ./ext/cargo-vendor/cap-primitives-3.2.0/src/fs/via_parent/symlink.rs
wasmtime-25.0.0 ./ext/cargo-vendor/cap-primitives-3.2.0/src/fs/via_parent/symlink.rs
wasmtime-24.0.0 ./ext/cargo-vendor/cap-primitives-3.2.0/src/fs/via_parent/symlink.rs
wasmtime-23.0.2 ./ext/cargo-vendor/cap-primitives-3.1.0/src/fs/via_parent/symlink.rs
wasmtime-22.0.0 ./ext/cargo-vendor/cap-primitives-3.1.0/src/fs/via_parent/symlink.rs
wasmtime-21.0.1 ./ext/cargo-vendor/cap-primitives-3.1.0/src/fs/via_parent/symlink.rs
wasmtime-20.0.2 ./ext/cargo-vendor/cap-primitives-3.1.0/src/fs/via_parent/symlink.rs
wasmtime-20.0.0 ./ext/cargo-vendor/cap-primitives-3.0.0/src/fs/via_parent/symlink.rs
wasmtime-18.0.3 ./ext/cargo-vendor/cap-primitives-2.0.1/src/fs/via_parent/symlink.rs
wasmtime-17.0.1 ./ext/cargo-vendor/cap-primitives-2.0.1/src/fs/via_parent/symlink.rs
wasmtime-17.0.0 ./ext/cargo-vendor/cap-primitives-2.0.1/src/fs/via_parent/symlink.rs
wasmtime-16.0.0 ./ext/cargo-vendor/cap-primitives-2.0.1/src/fs/via_parent/symlink.rs
wasmtime-15.0.1 ./ext/cargo-vendor/cap-primitives-2.0.1/src/fs/via_parent/symlink.rs
wasmtime-15.0.0 ./ext/cargo-vendor/cap-primitives-2.0.1/src/fs/via_parent/symlink.rs