honestly fuck windows but now it works

This commit is contained in:
Zastian Pretorius
2022-07-13 22:39:54 +01:00
parent 3132f3b54b
commit 47210dfd15
5 changed files with 102 additions and 12 deletions

View File

@@ -52,7 +52,6 @@ pub fn anime_stream(first_run: bool) {
println!("Invalid episode number");
}
}
loop{
let link = anime_link(title, ep_num as u64);
open_video(link);

View File

@@ -9,15 +9,23 @@ pub fn ln_read(){
let chapter_url = chapter_selector(&ln_url, selected_page);
selected_page = chapter_url.1;
let full_text = get_full_text(&chapter_url.0);
//write full_text to file called temp.txt
let mut file = File::create("/tmp/log_e").expect("Unable to create file");
file.write_all(full_text.as_bytes())
.expect("Unable to write to file");
//close file
file.sync_all().expect("Unable to sync file");
if cfg!(target_os = "windows"){
use dirs::home_dir;
let mut home = format!("{:?}",home_dir()).replace("\\\\","/");
home.drain(0..6);
home.drain(home.len()-2..home.len());
let mut file = File::create(format!("{}/AppData/Roaming/log_e",home)).expect("Unable to create file");
file.write_all(full_text.as_bytes())
.expect("Unable to write to file");
file.sync_all().expect("Unable to sync file");
}else{
let mut file = File::create("/tmp/log_e").expect("Unable to create file");
file.write_all(full_text.as_bytes())
.expect("Unable to write to file");
file.sync_all().expect("Unable to sync file");
};
//open temp.txt in cat for user to read
let _com = open_bat();
print!("\x1B[2J\x1B[1;1H");
}
}

View File

@@ -1,13 +1,26 @@
use std::io::Result;
use std::process::{Command, ExitStatus, Stdio};
#[allow(unused_assignments)]
pub fn open_bat() -> Result<ExitStatus> {
let termsize::Size {rows: _, cols} = termsize::get().unwrap();
let termsize::Size {rows: _, cols} = termsize::get().unwrap();
let mut path = String::new();
if cfg!(target_os = "windows"){
use dirs::home_dir;
let mut home = format!("{:?}",home_dir()).replace("\\\\","/");
home.drain(0..6);
home.drain(home.len()-2..home.len());
path = format!("{}/AppData/Roaming/log_e",home).to_string();
}
else{
path = "/tmp/log_e".to_string();
}
let soft_wrap = match Command::new("fold")
.arg("-s")
.arg("-w")
.arg((cols - 9).to_string())
.arg("/tmp/log_e")
.arg(path)
.stdout(Stdio::piped())
.spawn()
{