Cleanups pre-alpha
This commit is contained in:
parent
d65d511489
commit
5260aaa045
35
src/main.rs
35
src/main.rs
|
@ -1,7 +1,7 @@
|
|||
use clap::{Parser, Subcommand};
|
||||
use disk::Disk;
|
||||
|
||||
use crate::{analyzer::Analyzer, builder::DiskBuilder, downloader::ZipDownloader};
|
||||
use crate::{analyzer::Analyzer, builder::DiskBuilder};
|
||||
|
||||
pub mod analyzer;
|
||||
pub mod builder;
|
||||
|
@ -21,11 +21,6 @@ struct Cli {
|
|||
|
||||
#[derive(Subcommand)]
|
||||
enum Commands {
|
||||
/// Temporary command for testing the downloader module. This will be gone soon!
|
||||
Download {
|
||||
/// URL for the ZIP-file to download
|
||||
url: String,
|
||||
},
|
||||
/// Build a DOSContainer manifest into a VHD disk image.
|
||||
Build {
|
||||
/// Filename of the build manifest.
|
||||
|
@ -41,40 +36,12 @@ enum Commands {
|
|||
fn main() {
|
||||
let cli = Cli::parse();
|
||||
match &cli.command {
|
||||
Commands::Download { url } => {
|
||||
let mut downloader = ZipDownloader::new();
|
||||
downloader.download_zip(url, Some("Trying to get your stuff.")).unwrap();
|
||||
}
|
||||
Commands::Build { name } => {
|
||||
let manifest = manifest::Manifest::load(name.as_str()).unwrap();
|
||||
print_header();
|
||||
println!("{}", manifest.get_metadata());
|
||||
println!("{}", manifest);
|
||||
DiskBuilder::build(&manifest).expect("Failed building the disk.");
|
||||
/* let os = OperatingSystem::from_str(manifest.os.as_str()).unwrap();
|
||||
let mut disk = Disk::new(manifest.disktype.as_str(), manifest.os.as_str()).unwrap();
|
||||
disk.attach(manifest.diskname.as_str()).unwrap();
|
||||
disk.set_geometry(manifest.disksize).unwrap();
|
||||
let mut partition = Partition::fill_disk(&disk, None).unwrap();
|
||||
partition.set_partition_type(0x01);
|
||||
let mut filesystem = Fat::new(&disk, &partition, Some(os)).unwrap();
|
||||
let vbr = Vbr::from_os(&os, &filesystem);
|
||||
let mut sector2 = disk.read_sector(2).unwrap();
|
||||
sector2.copy_from_slice(
|
||||
&filesystem
|
||||
.allocation_table
|
||||
.as_bytes(fat::FatType::Fat12)
|
||||
.unwrap()[0..512],
|
||||
);
|
||||
let sysattribs = Attributes::new(true,true,true,true,false,false,false);
|
||||
filesystem.write_file(&os.get_iosys(), Some(sysattribs)).unwrap();
|
||||
disk.write_sector(vbr.as_bytes(), 1).unwrap();
|
||||
disk.write_sector(sector2, 2).unwrap();
|
||||
disk.partition_table.partitions[0] = Some(partition);
|
||||
disk.write_os_bootcode().unwrap();
|
||||
disk.write_partition_table().unwrap();
|
||||
disk.write_boot_signature().unwrap();
|
||||
disk.commit_storage().unwrap(); */
|
||||
}
|
||||
Commands::Analyze { name } => {
|
||||
print_header();
|
||||
|
|
|
@ -8,15 +8,14 @@ pub struct GameMetadata {
|
|||
publisher: String,
|
||||
year: u32,
|
||||
comment: String,
|
||||
filename: String,
|
||||
}
|
||||
|
||||
impl fmt::Display for GameMetadata {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"Title : {}\nPublisher : {}\nYear : {}\nFilename : {}\n",
|
||||
self.title, self.publisher, self.year, self.filename
|
||||
"Title : {}\nPublisher : {}\nYear : {}\n",
|
||||
self.title, self.publisher, self.year
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +23,7 @@ impl fmt::Display for GameMetadata {
|
|||
#[derive(Debug, Deserialize, Serialize)]
|
||||
pub struct DistFile {
|
||||
name: String,
|
||||
checksum: String,
|
||||
checksum: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
|
@ -41,12 +40,11 @@ pub struct Manifest {
|
|||
#[serde(default = "default_disktype")]
|
||||
pub disktype: String,
|
||||
pub distfiles: Vec<DistFile>,
|
||||
pub gamefiles: Option<Vec<String>>,
|
||||
pub os: String,
|
||||
#[serde(rename = "AUTOEXEC")]
|
||||
pub autoexec: String,
|
||||
pub autoexec: Option<String>,
|
||||
#[serde(rename = "CONFIG")]
|
||||
pub config: String,
|
||||
pub config: Option<String>,
|
||||
}
|
||||
|
||||
fn default_disktype() -> String {
|
||||
|
|
Loading…
Reference in New Issue