Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/third_party/rust/tokio/tests/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 818 B image not shown  

Quelle  fs_symlink_dir_windows.rs   Sprache: unbekannt

 
Spracherkennung für: .rs vermutete Sprache: Unknown {[0] [0] [0]} [Methode: Schwerpunktbildung, einfache Gewichte, sechs Dimensionen]

#![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // WASI does not support all fs operations
#![cfg(windows)]

use tempfile::tempdir;
use tokio::fs;

#[tokio::test]
async fn symlink_file_windows() {
    const FILE_NAME: &str = "abc.txt";

    let temp_dir = tempdir().unwrap();

    let dir1 = temp_dir.path().join("a");
    fs::create_dir(&dir1).await.unwrap();

    let file1 = dir1.as_path().join(FILE_NAME);
    fs::write(&file1, b"Hello File!").await.unwrap();

    let dir2 = temp_dir.path().join("b");
    fs::symlink_dir(&dir1, &dir2).await.unwrap();

    fs::write(&file1, b"new data!").await.unwrap();

    let file2 = dir2.as_path().join(FILE_NAME);

    let from = fs::read(&file1).await.unwrap();
    let to = fs::read(&file2).await.unwrap();

    assert_eq!(from, to);
}

[ Dauer der Verarbeitung: 0.36 Sekunden  ]