Skip to content

Instantly share code, notes, and snippets.

@jrcavani
jrcavani / tar-files-async.rs
Last active December 19, 2023 03:20
tar vs tokio-tar
use anyhow::Result;
use clap::Parser;
use futures::TryStreamExt;
use indicatif::{MultiProgress, ProgressBar, ProgressStyle};
use indicatif_log_bridge::LogWrapper;
#[allow(unused_imports)]
use log::{error, info};
use std::sync::Arc;
use tokio::fs::File;
use tokio::io::{AsyncWriteExt, BufReader, BufWriter};
// use file api
use anyhow::Result;
use std::fs::OpenOptions;
use std::io::{self, Write, Seek, SeekFrom};
use std::thread;
fn write_to_file_at_position(file_path: &str, data: &[u8], position: u64) -> io::Result<()> {
// Open the file in write mode and create it if it doesn't exist
let mut file = OpenOptions::new()
.write(true)