pub(super) fn create_sandbox_argv() -> Option<Vec<String>> {
    let current_binary_path = current_binary_path()?;
    let current_binary_name = current_binary_path.file_name()?.to_str()?;

    // The order of checks performed in this function is important.
    // Please do not reorder.
    //
    // 1. If the current binary supports running the sandbox mode, then use it.
    // This is important for `ic-replay` and `drun` where we do not control
    // the location of the sandbox binary.
    if RUNNABLE_AS_SANDBOX.contains(&current_binary_name) {
        let exec_path = current_binary_path.to_str()?.to_string();
        return Some(vec![exec_path, RUN_AS_CANISTER_SANDBOX_FLAG.to_string()]);
    }

    // 2. If the sandbox binary is in the same folder as the current binary, then
    // use it.
    let current_binary_folder = current_binary_path.parent()?;
    let sandbox_executable_path = current_binary_folder.join(SANDBOX_EXECUTABLE_NAME);
    if Path::exists(&sandbox_executable_path) {
        let exec_path = sandbox_executable_path.to_str()?.to_string();
        return Some(vec![exec_path]);
    }

    // 3. The two checks above cover all production use cases.
    // Find the sandbox binary for testing and local development.
    create_sandbox_argv_for_testing()
}
/// Gets the executable and arguments for spawning a canister sandbox.
Gets the executable and arguments for spawning a canister sandbox.
Gets the executable and arguments for spawning a canister sandbox .
pub(super) fn create_sandbox_argv() -> Option<Vec<String>> {
    let current_binary_path = current_binary_path()?;
    let current_binary_name = current_binary_path.file_name()?.to_str()?;
    // The order of checks performed in this function is important.
    // Please do not reorder.
    //
    // 1. If the current binary supports running the sandbox mode, then use it.
    // This is important for `ic-replay` and `drun` where we do not control
    // the location of the sandbox binary.
    if RUNNABLE_AS_SANDBOX.contains(&current_binary_name) {
        let exec_path = current_binary_path.to_str()?.to_string();
        return Some(vec![exec_path, RUN_AS_CANISTER_SANDBOX_FLAG.to_string()]);
    }
    // 2. If the sandbox binary is in the same folder as the current binary, then
    // use it.
    let current_binary_folder = current_binary_path.parent()?;
    let sandbox_executable_path = current_binary_folder.join(SANDBOX_EXECUTABLE_NAME);
    if Path::exists(&sandbox_executable_path) {
        let exec_path = sandbox_executable_path.to_str()?.to_string();
        return Some(vec![exec_path]);
    }
    // 3. The two checks above cover all production use cases.
    // Find the sandbox binary for testing and local development.
    create_sandbox_argv_for_testing()
}
pub ( super ) fn create_sandbox_argv ( ) -> Option < Vec < String > > { let current_binary_path = current_binary_path ( ) ? ; let current_binary_name = current_binary_path . file_name ( ) ? . to_str ( ) ? ; // The order of checks performed in this function is important. // Please do not reorder. // // 1. If the current binary supports running the sandbox mode, then use it. // This is important for `ic-replay` and `drun` where we do not control // the location of the sandbox binary. if RUNNABLE_AS_SANDBOX . contains ( & current_binary_name ) { let exec_path = current_binary_path . to_str ( ) ? . to_string ( ) ; return Some ( vec ! [ exec_path RUN_AS_CANISTER_SANDBOX_FLAG to_string ( ) ] ) ; } // 2. If the sandbox binary is in the same folder as the current binary, then // use it. let current_binary_folder = current_binary_path . parent ( ) ? ; let sandbox_executable_path = current_binary_folder . join ( SANDBOX_EXECUTABLE_NAME ) ; if Path :: exists ( & sandbox_executable_path ) { let exec_path = sandbox_executable_path . to_str ( ) ? . to_string ( ) ; return Some ( vec ! [ exec_path ] ) ; } // 3. The two checks above cover all production use cases. // Find the sandbox binary for testing and local development. create_sandbox_argv_for_testing ( ) }
Gets the executable and arguments for spawning a canister sandbox.
Gets the executable and arguments for spawning a canister sandbox .