You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: preview1_file_truncation.rs
    path of file: ./repos/wasmtime/crates/test-programs/src/bin
    
    the code of the file until where you have to start completion: use std::{env, process};
use test_programs::preview1::open_scratch_directory;

unsafe fn test_file_truncation(dir_fd: wasi::Fd) {
    const FILENAME: &str = "test.txt";

    // Open a file for writing
    let file_fd = wasi::path_open(
        dir_fd,
        0,
        FILENAME,
        wasi::OFLAGS_CREAT,
        wasi::RIGHTS_FD_WRITE,
        0,
        0,
    )
    .expect("creating a file for writing");

    // Write to the file
    le
    
fn main() {
    let mut args = env::args();
    let prog = args.next().unwrap();
    let arg = if let Some(arg) = args.next() {
        arg
    } else {
        eprintln!("usage: {} <scratch directory>", prog);
        process::exit(1);
    };

    // Open scratch directory
    let dir_fd = match open_scratch_directory(&arg) {
        Ok(dir_fd) => dir_fd,
        Err(err) => {
            eprintln!("{}", err);
            process::exit(1)
        }
    };

    // Run the tests.
    unsafe { test_file_truncation(dir_fd) }
}