File tree 2 files changed +25
-0
lines changed
2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -9,3 +9,6 @@ edition = "2024"
9
9
tar = " 0.4.44"
10
10
flate2 = " 1.1.1"
11
11
clap = { version = " 4.5.37" , features = [" derive" ] }
12
+
13
+ [features ]
14
+ extract-meta = []
Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ use clap::Parser;
2
2
use flate2:: read:: GzDecoder ;
3
3
use std:: collections:: HashMap ;
4
4
use std:: fs:: File ;
5
+ #[ cfg( feature = "extract-meta" ) ]
6
+ use std:: io:: Write ;
5
7
use std:: io:: { Read , Seek , SeekFrom } ;
6
8
use std:: path:: PathBuf ;
7
9
use tar:: { Archive , Entry } ;
@@ -52,6 +54,26 @@ fn main() {
52
54
. read_to_string ( & mut buf)
53
55
. expect ( "failed to read asset meta" ) ;
54
56
57
+ #[ cfg( feature = "extract-meta" ) ]
58
+ {
59
+ let path = paths. get ( & id) . expect ( "Can't unpack meta with no path" ) ;
60
+
61
+ let parent = path
62
+ . parent ( )
63
+ . expect ( "cannot get parent of root (this should not be possible)" ) ;
64
+
65
+ let meta_file = parent. join ( format ! (
66
+ "{}.meta" ,
67
+ path. file_name( )
68
+ . expect( "no meta filename?" )
69
+ . to_string_lossy( )
70
+ ) ) ;
71
+
72
+ std:: fs:: create_dir_all ( parent) . expect ( "Failed to unpack" ) ;
73
+ let mut w = File :: create ( meta_file) . expect ( "failed to create file" ) ;
74
+ w. write ( buf. as_bytes ( ) ) . expect ( "failed to write .meta file" ) ;
75
+ }
76
+
55
77
if buf. lines ( ) . any ( |e| e == "folderAsset: yes" ) {
56
78
paths. remove ( & id) ;
57
79
}
You can’t perform that action at this time.
0 commit comments