new file: output
modified: src/main.rs modified: src/objects.rs modified: src/xobjects.rs
This commit is contained in:
parent
d4de8dc8e2
commit
c2b6f178c9
18
src/main.rs
18
src/main.rs
@ -1,6 +1,7 @@
|
|||||||
use std::{fs::File, io::{Read, Write}};
|
use std::{fs::File, io::{Read, Write}};
|
||||||
use env_logger::Builder;
|
use env_logger::Builder;
|
||||||
use log::{error, info, LevelFilter};
|
use log::{error, info, LevelFilter};
|
||||||
|
use xobjects::{XArgument, XSomeList};
|
||||||
|
|
||||||
mod objects;
|
mod objects;
|
||||||
mod xobjects;
|
mod xobjects;
|
||||||
@ -25,8 +26,21 @@ fn main() {
|
|||||||
match f.read_to_end(&mut buf) {
|
match f.read_to_end(&mut buf) {
|
||||||
Ok(n) => {
|
Ok(n) => {
|
||||||
let data = &buf[..n];
|
let data = &buf[..n];
|
||||||
let xdb = deserializer::parse_bytes(data);
|
let mut xdb = deserializer::parse_bytes(data);
|
||||||
//info!("XDB: {:?}", xdb);
|
//info!("XDB: {:#?}", xdb);
|
||||||
|
if let XSomeList::TrackList(tracks) = &mut xdb.find_dataset(1).child {
|
||||||
|
let mut item = (*tracks.last().unwrap()).clone();
|
||||||
|
let mut xargs = Vec::new();
|
||||||
|
xargs.push(XArgument { arg_type: 1, val: String::from("They beat you") });
|
||||||
|
xargs.push(XArgument { arg_type: 3, val: String::from("IC3PEAK EP") });
|
||||||
|
xargs.push(XArgument { arg_type: 4, val: String::from("IC3PEAK") });
|
||||||
|
xargs.push(XArgument { arg_type: 6, val: String::from("MPEG audio file")});
|
||||||
|
xargs.push(XArgument { arg_type: 2, val: String::from(":iPod_Control:Music:F38:ZJUQ.mp3") });
|
||||||
|
item.args = xargs;
|
||||||
|
item.data.number_of_strings = 5;
|
||||||
|
item.data.unique_id = 99;
|
||||||
|
tracks.push(item);
|
||||||
|
}
|
||||||
let mut op = File::create("outdb").unwrap();
|
let mut op = File::create("outdb").unwrap();
|
||||||
info!("Write res: {:?}", op.write(&serializer::to_bytes(xdb)));
|
info!("Write res: {:?}", op.write(&serializer::to_bytes(xdb)));
|
||||||
},
|
},
|
||||||
|
@ -50,7 +50,7 @@ impl From<ChunkType> for [u8; 4] {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, PartialEq, Debug)]
|
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Copy)]
|
||||||
pub struct ChunkHeader {
|
pub struct ChunkHeader {
|
||||||
pub chunk_type: [u8; 4],
|
pub chunk_type: [u8; 4],
|
||||||
pub end_of_chunk: u32,
|
pub end_of_chunk: u32,
|
||||||
@ -72,7 +72,7 @@ pub struct Database {
|
|||||||
unk2: [u8; 20]
|
unk2: [u8; 20]
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
|
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Copy)]
|
||||||
pub struct DataSet {
|
pub struct DataSet {
|
||||||
pub data_type: u32
|
pub data_type: u32
|
||||||
}
|
}
|
||||||
@ -86,10 +86,10 @@ pub struct AlbumItem {
|
|||||||
unknown1: u32
|
unknown1: u32
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, PartialEq, Debug)]
|
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Copy)]
|
||||||
pub struct TrackItem {
|
pub struct TrackItem {
|
||||||
number_of_strings: u32, // number of mhod's count
|
pub number_of_strings: u32, // number of mhod's count
|
||||||
unique_id: u32,
|
pub unique_id: u32,
|
||||||
visible: u32,
|
visible: u32,
|
||||||
filetype: u32,
|
filetype: u32,
|
||||||
type1: u8,
|
type1: u8,
|
||||||
|
@ -15,7 +15,7 @@ pub struct XDataSet {
|
|||||||
pub child: XSomeList
|
pub child: XSomeList
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, serde::Serialize)]
|
#[derive(Debug, serde::Serialize, Clone)]
|
||||||
pub struct XTrackItem {
|
pub struct XTrackItem {
|
||||||
pub header: ChunkHeader,
|
pub header: ChunkHeader,
|
||||||
pub data: TrackItem,
|
pub data: TrackItem,
|
||||||
@ -57,7 +57,7 @@ pub struct XLetterJump {
|
|||||||
pub v: Vec<JumpTable>
|
pub v: Vec<JumpTable>
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, serde::Serialize)]
|
#[derive(Debug, serde::Serialize, Clone)]
|
||||||
pub struct XArgument {
|
pub struct XArgument {
|
||||||
pub arg_type: u32,
|
pub arg_type: u32,
|
||||||
pub val: String
|
pub val: String
|
||||||
|
Loading…
x
Reference in New Issue
Block a user