@@ -435,19 +435,21 @@ AOTIModelPackageLoader::AOTIModelPackageLoader(
435
435
436
436
std::vector<std::string> found_filenames;
437
437
for (uint32_t i =0 ; i < zip_archive.m_total_files ; i++) {
438
- uint32_t filename_len =
438
+ uint32_t zip_filename_len =
439
439
mz_zip_reader_get_filename (&zip_archive, i,nullptr ,0 );
440
- if (filename_len ==0 ) {
440
+ if (zip_filename_len ==0 ) {
441
441
throw std::runtime_error (" Failed to read filename" );
442
442
}
443
- // filename_len returned by mz_zip_reader_get_filename includes the null
444
- // terminator, so we need to subtract 1 here
445
- std::stringfilename_str (filename_len -1 ,' \0 ' );
443
+ // zip_filename_len returned by mz_zip_reader_get_filename includes the null
444
+ // terminator, so we need to subtract 1 here.
445
+ std::stringzip_filename_str (zip_filename_len -1 ,' \0 ' );
446
+ // zip_filename_str can't be normalize_path_separator, because it should be
447
+ // as index for mz_zip_reader_extract_file_to_file.
446
448
if (!mz_zip_reader_get_filename (
447
- &zip_archive, i,filename_str .data (),filename_len )) {
449
+ &zip_archive, i,zip_filename_str .data (),zip_filename_len )) {
448
450
throw std::runtime_error (" Failed to read filename" );
449
451
}
450
- found_filenames.push_back (normalize_path_separator (filename_str) );
452
+ found_filenames.push_back (zip_filename_str );
451
453
}
452
454
453
455
if (found_filenames.empty ()) {
@@ -504,18 +506,17 @@ AOTIModelPackageLoader::AOTIModelPackageLoader(
504
506
.append (filename);
505
507
}
506
508
507
- output_path_str =normalize_path_separator (output_path_str);
508
-
509
+ std::string output_file_path =normalize_path_separator (output_path_str);
509
510
LOG (INFO) <<" Extract file:" << filename_str <<" to"
510
- <<output_path_str ;
511
+ <<output_file_path ;
511
512
512
513
// Create the parent directory if it doesn't exist
513
- size_t parent_path_idx =output_path_str .find_last_of (k_separator);
514
+ size_t parent_path_idx =output_file_path .find_last_of (k_separator);
514
515
if (parent_path_idx == std::string::npos) {
515
516
throw std::runtime_error (
516
- " Failed to find parent path in" +output_path_str );
517
+ " Failed to find parent path in" +output_file_path );
517
518
}
518
- std::string parent_path =output_path_str .substr (0 , parent_path_idx);
519
+ std::string parent_path =output_file_path .substr (0 , parent_path_idx);
519
520
if (!recursive_mkdir (parent_path)) {
520
521
throw std::runtime_error (fmt::format (
521
522
" Failed to create directory {}: {}" ,
@@ -525,22 +526,22 @@ AOTIModelPackageLoader::AOTIModelPackageLoader(
525
526
526
527
// Extracts file to the temp directory
527
528
mz_bool b_extract =mz_zip_reader_extract_file_to_file (
528
- &zip_archive, filename_str.c_str (),output_path_str .c_str (),0 );
529
+ &zip_archive, filename_str.c_str (),output_file_path .c_str (),0 );
529
530
if (b_extract == MZ_FALSE) {
530
531
throw std::runtime_error (fmt::format (
531
- " Failed to extract file {} to {}" , filename_str,output_path_str ));
532
+ " Failed to extract file {} to {}" , filename_str,output_file_path ));
532
533
}
533
534
534
535
// Save the file for bookkeeping
535
- size_t extension_idx =output_path_str .find_last_of (' .' );
536
+ size_t extension_idx =output_file_path .find_last_of (' .' );
536
537
if (extension_idx != std::string::npos) {
537
- std::string filename_extension =output_path_str .substr (extension_idx);
538
+ std::string filename_extension =output_file_path .substr (extension_idx);
538
539
if (filename_extension ==" .cpp" ) {
539
- cpp_filename =output_path_str ;
540
+ cpp_filename =output_file_path ;
540
541
}else if (filename_extension ==object_file_ext ()) {
541
- obj_filenames.push_back (output_path_str );
542
+ obj_filenames.push_back (output_file_path );
542
543
}else if (filename_extension ==extension_file_ext ()) {
543
- so_filename =output_path_str ;
544
+ so_filename =output_file_path ;
544
545
}
545
546
}
546
547
}