| 303 | } |
| 304 | |
| 305 | fn assets(&mut self, input: &Path) -> io::Result<()> { |
| 306 | let mut added = FxHashSet::default(); |
| 307 | for (path, hash) in &self.costumes { |
| 308 | if added.contains(hash) { |
| 309 | continue; |
| 310 | } |
| 311 | added.insert(hash); |
| 312 | let (_, extension) = path.rsplit_once('.').unwrap(); |
| 313 | self.zip |
| 314 | .start_file(format!("{hash}.{extension}"), SimpleFileOptions::default())?; |
| 315 | let file = File::open(input.join(&**path)); |
| 316 | io::copy(&mut file?, &mut self.zip)?; |
| 317 | } |
| 318 | if self.srcpkg_hash.is_some() { |
| 319 | let hash = self.srcpkg_hash.take().unwrap(); |
| 320 | let data = self.srcpkg.take().unwrap(); |
| 321 | self.zip |
| 322 | .start_file(format!("{hash}.svg"), SimpleFileOptions::default())?; |
| 323 | self.zip.write_all(&data)?; |
| 324 | } |
| 325 | Ok(()) |
| 326 | } |
| 327 | |
| 328 | pub fn begin_node(&mut self, node: Node) -> io::Result<()> { |
| 329 | write_comma_io(&mut self.zip, &mut self.node_comma)?; |