-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
95 lines (91 loc) · 3.54 KB
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
use std::io::{Write, Read};
use std::path::Path;
//{fs, };
fn main() {
const BRAIN_SAVE_URL: &str = "https://github.com/sonicrules1234/aiml_ported/releases/download/brain_save/brain_save.zip";
const ALICE_BRAIN_URL: &str = "https://github.com/sonicrules1234/aiml_ported/releases/download/alice_brain/alice_brain.zip";
if !Path::new("alice_brain").exists() {
let mut alice_brain_zip: Vec<u8> = Vec::new();
ureq::get(ALICE_BRAIN_URL).call().unwrap().into_reader().read_to_end(&mut alice_brain_zip).unwrap();
let mut alice_brain = std::fs::File::create("alice_brain.zip").unwrap();
alice_brain.write_all(alice_brain_zip.as_slice()).unwrap();
drop(alice_brain);
let alice_brain = std::fs::File::open("alice_brain.zip").unwrap();
let mut ab_archive = zip::ZipArchive::new(alice_brain).unwrap();
ab_archive.extract(".").unwrap();
}
if !Path::new("brain_save").exists() {
let mut brain_save_zip: Vec<u8> = Vec::new();
ureq::get(BRAIN_SAVE_URL).call().unwrap().into_reader().read_to_end(&mut brain_save_zip).unwrap();
let mut brain_save = std::fs::File::create("brain_save.zip").unwrap();
brain_save.write_all(brain_save_zip.as_slice()).unwrap();
drop(brain_save);
let brain_save = std::fs::File::open("brain_save.zip").unwrap();
let mut bs_archive = zip::ZipArchive::new(brain_save).unwrap();
bs_archive.extract(".").unwrap();
}
/*
for i in 0..ab_archive.len() {
let mut file = ab_archive.by_index(i).unwrap();
let outpath = match file.enclosed_name() {
Some(path) => path.to_owned(),
None => continue,
};
{
let comment = file.comment();
if !comment.is_empty() {
println!("File {} comment: {}", i, comment);
}
}
if (*file.name()).ends_with('/') {
println!("File {} extracted to \"{}\"", i, outpath.display());
fs::create_dir_all(&outpath).unwrap();
} else {
println!(
"File {} extracted to \"{}\" ({} bytes)",
i,
outpath.display(),
file.size()
);
if let Some(p) = outpath.parent() {
if !p.exists() {
fs::create_dir_all(&p).unwrap();
}
}
let mut outfile = fs::File::create(&outpath).unwrap();
io::copy(&mut file, &mut outfile).unwrap();
}
}
for i in 0..bs_archive.len() {
let mut file = bs_archive.by_index(i).unwrap();
let outpath = match file.enclosed_name() {
Some(path) => path.to_owned(),
None => continue,
};
{
let comment = file.comment();
if !comment.is_empty() {
println!("File {} comment: {}", i, comment);
}
}
if (*file.name()).ends_with('/') {
println!("File {} extracted to \"{}\"", i, outpath.display());
fs::create_dir_all(&outpath).unwrap();
} else {
println!(
"File {} extracted to \"{}\" ({} bytes)",
i,
outpath.display(),
file.size()
);
if let Some(p) = outpath.parent() {
if !p.exists() {
fs::create_dir_all(&p).unwrap();
}
}
let mut outfile = fs::File::create(&outpath).unwrap();
io::copy(&mut file, &mut outfile).unwrap();
}
}
*/
}