@@ -7,6 +7,7 @@ use slint::ComponentHandle;
7
7
use tokio:: runtime:: Runtime ;
8
8
use crate :: dirs:: paths;
9
9
use crate :: slint_types:: ColdClearWaitWindow ;
10
+ use zip:: ZipArchive ;
10
11
11
12
enum LoadingIPCMessage {
12
13
AdvanceTo (
@@ -245,4 +246,85 @@ pub fn download_cold_clear(version: &str) -> Result<(), reqwest::Error> {
245
246
window. set_interrupted ( true ) ;
246
247
247
248
return window_thread. join ( ) . expect ( "Failed to join window thread" ) ;
249
+ }
250
+
251
+ fn get_path_score ( path : & str ) -> i8 {
252
+ #[ cfg( target_arch = "x86_64" ) ]
253
+ {
254
+ let pos_keywords = [
255
+ "x64" ,
256
+ "amd64" ,
257
+ "x86_64"
258
+ ] ;
259
+
260
+ for keyword in pos_keywords. iter ( ) {
261
+ if path. contains ( keyword) {
262
+ return 1 ;
263
+ }
264
+ }
265
+
266
+ let neg_keywords = [
267
+ "x86" ,
268
+ "i386" ,
269
+ "i686"
270
+ ] ;
271
+
272
+ for keyword in neg_keywords. iter ( ) {
273
+ if path. contains ( keyword) {
274
+ return -1 ;
275
+ }
276
+ }
277
+
278
+ return 0 ;
279
+ }
280
+
281
+ #[ cfg( target_arch = "x86" ) ]
282
+ {
283
+ let neg_keywords = [
284
+ "x64" ,
285
+ "amd64" ,
286
+ "x86_64"
287
+ ] ;
288
+
289
+ for keyword in neg_keywords. iter ( ) {
290
+ if path. contains ( keyword) {
291
+ return -1 ;
292
+ }
293
+ }
294
+
295
+ let pos_keywords = [
296
+ "x86" ,
297
+ "i386" ,
298
+ "i686"
299
+ ] ;
300
+
301
+ for keyword in pos_keywords. iter ( ) {
302
+ if path. contains ( keyword) {
303
+ return 1 ;
304
+ }
305
+ }
306
+
307
+ return 0 ;
308
+ }
309
+
310
+ #[ allow( unreachable_code) ] {
311
+ return 0 ;
312
+ }
313
+ }
314
+
315
+ pub fn unpack_cold_clear ( version : & str ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
316
+ let save_path = paths:: get_cold_clear_download_path ( version) ;
317
+ let save_path = save_path. as_path ( ) ;
318
+
319
+ if !save_path. exists ( ) {
320
+ download_cold_clear ( version) ?;
321
+ }
322
+
323
+ let save_path = save_path. to_str ( ) . unwrap ( ) ;
324
+
325
+ let zip_file = std:: fs:: File :: open ( save_path) ?;
326
+
327
+ let mut zip_archive = ZipArchive :: new ( zip_file) ?;
328
+
329
+ todo ! ( ) ; // TODO: Extract, flatten, select (path_score) and move library files
248
330
}
0 commit comments