⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 arj_arcv.c

📁 open arj source
💻 C
📖 第 1 页 / 共 5 页
字号:
    }   }   if(uncompsize>0L)    uncompsize-=resume_position;  } } if(store_by_suffix)  if(search_for_extension(filename, archive_suffixes))   method=0; if(properties.fsize==0L)  method=0; if(hollow_mode==HM_CRC)  method=9; else if(hollow_mode==HM_NO_CRC)  method=8; if(!no_file_activity)  cur_pos=ftell(aostream); cur_time_stamp(&cur_time); password_modifier=(char)ts_native(&cur_time, OS); arj_flags=0; far_strcpyn(comment, (char FAR *)hdr_comment, COMMENT_MAX); if(continued_prevvolume&&first_hdr_size<FIRST_HDR_SIZE_V) {  first_hdr_size=FIRST_HDR_SIZE_V;  hdr_filename=&header[first_hdr_size]; } if(fix_longnames) {  res_len=(exclude_paths==EP_BASEDIR&&resolve_longname(ea_res, target_dir))?          strlen(ea_res):strlen(target_dir);  lfn_xlated=resolve_longname(ea_res, filename); } else {  res_len=strlen(target_dir);  lfn_xlated=0; } if(exclude_paths==EP_BASEDIR)  default_case_path(hdr_filename, (lfn_xlated?ea_res:filename)+res_len); else if(exclude_paths==EP_PATH)  split_name(lfn_xlated?ea_res:filename, NULL, hdr_filename); else  default_case_path(hdr_filename, lfn_xlated?ea_res:filename); /* Collect data for extended headers: EAs and maybe more */ if(!continued_prevvolume) {  /* Flush headers from the previous file */  if(eh!=NULL)   eh_release(eh);  eh=eh_alloc();  /* For the UNIX special files, collect and store their properties */  if(file_type==ARJT_UXSPECIAL)  {   if(query_uxspecial(&raw_eh, filename, &properties))   {    msg_cprintf(H_ERR, M_CANT_QUERY_UXSPEC);    return(0);   }   eh_append(eh, UXSPECIAL_ID, raw_eh, get_uxspecial_size(raw_eh));   farfree(raw_eh);  }  /* Query the file owner */  if(do_chown&&!query_owner(&raw_eh, filename, do_chown))  {   eh_append(eh, (do_chown==OWNSTG_ID)?OWNER_ID_NUM:OWNER_ID, raw_eh, get_owner_size(raw_eh));   farfree(raw_eh);  }  /* Pick extended attributes, if any */  if(ea_supported&&!hollow_mode)  {   ea_size=0;   if(query_ea(&raw_eh, filename, lfn_xlated))    return(0);   if(get_num_eas(raw_eh)==0)    farfree(raw_eh);   else   {    ea_size=get_eablk_size(raw_eh);    ea_blk=(char FAR *)farmalloc_msg(ea_size+3+MEMPACK_OVERHEAD);    mempack.comp=ea_blk+3;    mempack.orig=raw_eh;    mempack.origsize=ea_size;    ea_blk[1]=(unsigned char)(ea_size%256U);    ea_blk[2]=(unsigned char)(ea_size/256U);    mempack.method=custom_method?method_specifier:1;    pack_mem(&mempack);    ea_blk[0]=(char)mempack.method;    farfree(raw_eh);    eh_append(eh, EA_ID, ea_blk, mempack.compsize+3);    farfree(ea_blk);   }  } } /* Prepare for flushing the extended headers */ if(eh!=NULL) {  ext_hdr_capacity=multivolume_option?get_volfree(LONG_MAX):LONG_MAX;  if(ext_hdr_capacity==0)   ext_hdr_capacity=1; } entry_pos=split_name(hdr_filename, NULL, NULL); if(translate_path(hdr_filename))  arj_flags|=PATHSYM_FLAG; calc_comment_offset(); far_strcpyn((char FAR *)hdr_comment, comment, COMMENT_MAX); lfn=0; #if TARGET==DOS  if(lfn_supported==LFN_SUPPORTED&&dual_name)  {   far_strcpyn(comment, (char FAR *)hdr_filename, FILENAME_MAX);   get_canonical_shortname(hdr_comment+FILENAME_MAX, filename);   if(exclude_paths==EP_PATH)    split_name(hdr_comment+FILENAME_MAX, NULL, hdr_filename);   else    default_case_path(hdr_filename, hdr_comment+FILENAME_MAX);   calc_comment_offset();   far_strcpyn((char FAR *)hdr_comment, comment, FILENAME_MAX);   entry_pos=split_name(hdr_filename, NULL, NULL);   if(translate_path(hdr_filename))    arj_flags|=PATHSYM_FLAG;  }  else if(lfn_supported==LFN_COMP&&dual_name)  {   get_canonical_longname(hdr_comment+FILENAME_MAX, filename);   if(!file_exists(hdr_comment+FILENAME_MAX))   {    errors++;    error_report();    msg_cprintf(H_ERR, M_CANTOPEN, hdr_comment+FILENAME_MAX);    nputlf();    write_index_entry(idxid_fault);    return(0);   }   if(exclude_paths==EP_PATH)    split_name(hdr_comment+FILENAME_MAX, NULL, hdr_comment);   else    default_case_path(hdr_comment, hdr_comment+FILENAME_MAX);  }  if(lfn_supported==LFN_SUPPORTED&&lfn_mode!=LFN_ALL)  {   if(win32_platform)   {    get_canonical_shortname(hdr_comment, filename);    if(!strcmp(filename, hdr_comment))     lfn=1;   }   else   {    get_canonical_longname(hdr_comment, filename);    get_canonical_shortname(hdr_comment+FILENAME_MAX, filename);    if(!strcmp(hdr_comment+FILENAME_MAX, hdr_comment))     lfn=1;   }   far_strcpyn((char FAR *)hdr_comment, comment, FILENAME_MAX);  } #endif calc_basic_hdr_size(); if(garble_enabled)  arj_flags|=GARBLED_FLAG; if(continued_prevvolume)  arj_flags|=EXTFILE_FLAG; write_header(); if(!no_file_activity)  data_pos=ftell(aostream); addition_msg(is_update, is_replace, lfn_xlated?ea_res:filename); init_packing(data_pos, 1); if(debug_enabled&&strchr(debug_opt, 't')!=NULL)  st_ticks=get_ticks(); if(method==8) {  compsize=0L;  crc32term=CRC_MASK;  origsize=properties.fsize; } else if(file_type==ARJT_BINARY||file_type==ARJT_TEXT) {  if(file_type==ARJT_TEXT)  {   bck_method=method;   pack_file_proc(data_pos);   if(type_override<FT_TEXT_FORCED&&uncompsize>=MIN_TEXT_SIZE&&origsize*5L<uncompsize*4L)   {    msg_cprintf(H_HL|H_NFMT, M_REARCHIVING, filename);    file_type=ARJT_BINARY;    file_close(encstream);    encstream=0L;    if(open_input_file())     return(0);    method=bck_method;    addition_msg(is_update, is_replace, lfn_xlated?ea_res:filename);    init_packing(data_pos, 0);   }  }  if(file_type==ARJT_BINARY)   pack_file_proc(data_pos); } if(eh!=NULL)  proc_ext_hdr(EHUF_SETFLAGS); if(verbose_display==VERBOSE_STD)  msg_cprintf(H_HL|H_NFMT, M_N_BYTES, compsize); if(debug_enabled&&strchr(debug_opt, 't')!=NULL)  msg_cprintf(H_HL|H_NFMT, M_N_TICKS, st_ticks=get_ticks()-st_ticks); if(method!=8&&(file_type==ARJT_BINARY||file_type==ARJT_TEXT)) {  if(ferror(encstream))  {   err_id=1;   errors++;   nputlf();   error_report();   msg_cprintf(H_ERR, M_CANTREAD);   nputlf();   write_index_entry(idxid_fault);  }  else   fclose(encstream); } encstream=NULL; if(!no_file_activity)  data_pos=ftell(aostream); file_crc=crc32term^CRC_MASK; if(volume_flag_set)  arj_flags|=VOLUME_FLAG; fm_store(&file_mode, host_os, (unsigned int)attrib); ftime_stamp=ftime; atime_stamp=atime; ctime_stamp=ctime; host_data=0; ext_flags=chapter_number=total_chapters; fill_general_hdr(); #if TARGET==DOS  if(dual_name||lfn)  {   host_os=OS;   strupper(filename);   strupper(hdr_filename);  } #endif if(lowercase_names)  strlower(hdr_filename); create_header(0); if(!no_file_activity)  fseek(aostream, cur_pos, SEEK_SET); far_strcpy(tmp_filename, (char FAR *)filename); if(whole_files_in_mv&&volume_flag_set&&total_files>0) {  if(!no_file_activity)   file_chsize(aostream, cur_pos);  msg_cprintf(H_HL, M_FSTAT_1);  comment_entries++;  origsize=0L;  resume_position=0L;  continued_prevvolume=0;  return(1); } write_header(); if(!no_file_activity)  fseek(aostream, data_pos, SEEK_SET); if(volume_flag_set) {  resume_position+=origsize;  continued_prevvolume=1;  mvfile_type=file_type; } else {  resume_position=0L;  continued_prevvolume=0; } total_uncompressed+=origsize; total_compressed+=compsize; ratio=calc_percentage(compsize, origsize); if(!debug_enabled||strchr(debug_opt, 'x')==NULL) {  msg_cprintf(H_HL, M_FSTAT_2, ratio/10, ratio%10);  #if defined(HAVE_EAS)   if(ea_supported&&!volume_flag_set&&ea_size!=0)    msg_cprintf(H_HL, M_EA_STATS_STG, ea_size);  #endif  if(file_type==ARJT_UXSPECIAL&&eh_lookup(eh, UXSPECIAL_ID)!=NULL)  {   raw_eh=eh_lookup(eh, UXSPECIAL_ID)->raw;   uxspecial_stats(raw_eh, UXSTATS_SHORT);  }  msg_cprintf(0, lf); } if(err_id==0&&user_wants_fail) {  errors++;  error_report();  write_index_entry(idxid_fault); } if(create_index) {  if(detailed_index)  {   timestamp_to_str(timetext, &ftime_stamp);   if(msg_fprintf(idxstream, M_IDX_FIELD, timetext, origsize, compsize, ratio/1000, ratio%1000, filename)<0)    error(M_DISK_FULL);  }  else  {   if(msg_fprintf(idxstream, M_FILENAME_FORM, filename)<0)    error(M_DISK_FULL);  } } total_files++; if(host_os==OS_WIN95||host_os==OS_WINNT)  total_longnames++; if(eh!=NULL)  proc_ext_hdr(EHUF_COMMIT); return(1);}/* Packs a file, with statistics update */int pack_file_stub(int is_update, int is_replace){ int rc; rc=pack_file(is_update, is_replace); if(rc==1)  total_written+=origsize; else  {  total_size-=origsize;    if(rc==-1)   rc=0; } return(rc);}/* Inserts a chapter mark into the archive */int create_chapter_mark(){ if(multivolume_option&&get_volfree(MULTIVOLUME_INCREMENT)<MULTIVOLUME_INCREMENT) {  volume_flag_set=1;  comment_entries++;  return(1); } file_type=5; msg_sprintf(filename, M_CHAPMARK_FORMAT, total_chapters); first_hdr_size=FIRST_HDR_SIZE; hdr_filename=&header[first_hdr_size]; far_strcpyn((char FAR *)hdr_filename, (char FAR *)filename, FILENAME_MAX); calc_comment_offset(); hdr_comment[0]='\0'; msg_cprintf(H_HL, M_ADDING); if(verbose_display==VERBOSE_STD)  msg_cprintf(0, M_CHAPTER); msg_cprintf(H_HL|H_NFMT, M_LIST_FORM, format_filename(filename)); calc_basic_hdr_size(); arj_flags=0; entry_pos=0; cur_time_stamp(&ftime_stamp); password_modifier=(char)ts_native(&ftime_stamp, OS); compsize=origsize=0L; volume_flag_set=0; file_crc=0L; fm_store(&file_mode, OS_DOS, 0); host_data=0; if(eh!=NULL) {  eh_release(eh);  eh=NULL; } ext_flags=chapter_number=total_chapters; fill_general_hdr(); create_header(0); write_header(); write_index_entry(nullstr); msg_cprintf(H_HL, M_NO_RATIO); total_files++; return(1);}/* Stores volume label in the archive */#ifdef HAVE_VOL_LABELSint store_label(){ ATTRIB tmp_attr; unsigned long vftime_native;  fm_store(&file_mode, OS_DOS, 0); if(file_getlabel(filename, label_drive, (ATTRIB *)&tmp_attr, &vftime_native)) {  msg_cprintf(H_ERR, M_CANT_QUERY_LABEL);  errors++;  write_index_entry(idxid_fault);  return(0); } ts_store(&ftime_stamp, OS, vftime_native); fm_store(&file_mode, host_os, tmp_attr); if(filename[0]=='\0')  return(0); if(multivolume_option&&get_volfree(MULTIVOLUME_INCREMENT)<MULTIVOLUME_INCREMENT) {  volume_flag_set=1;  comment_entries++;  return(1); } file_type=ARJT_LABEL; first_hdr_size=FIRST_HDR_SIZE; hdr_filename=&header[first_hdr_size]; far_strcpyn((char FAR *)hdr_filename, (char FAR *)filename, FILENAME_MAX); calc_comment_offset(); hdr_comment[0]='\0'; msg_cprintf(H_HL, M_ADDING); if(verbose_display==VERBOSE_STD)  msg_cprintf(0, M_LABEL_FILE); msg_cprintf(H_HL|H_NFMT, M_LIST_FORM, format_filename(filename)); calc_basic_hdr_size(); arj_flags=0; entry_pos=0; password_modifier=0; compsize=origsize=0L; volume_flag_set=0; file_crc=0L; host_data=0; ext_flags=chapter_number=total_chapters; if(eh!=NULL) {  eh_release(eh);  eh=NULL; } fill_general_hdr(); create_header(0); write_header(); write_index_entry(nullstr); msg_cprintf(H_HL, M_NO_RATIO); total_files++; return(1);}#endif/* Joins an archive to another archive */FILE_COUNT copy_archive(){ char name[FILENAME_MAX]; FILE_COUNT rc;                       	/* (returned) File count */ FILE_COUNT i; FILE *arc; char enc_type; rc=0; for(i=0; i<flist_main.files; i++) {  flist_retrieve(name, NULL, &flist_main, i);  arc=file_open_noarch(name, m_rb);  msg_cprintf(H_HL|H_NFMT, M_PROCESSING_ARCHIVE, name);  if(find_header(0, arc)<0L)  {   msg_cprintf(H_HL|H_NFMT, M_NOT_ARJ_ARCHIVE, name);   nputlf();   errors++;   cfa_store(i, FLFLAG_SKIPPED);  }  else  {   read_header(0, arc, name);   if((arj_flags&DUAL_NAME_FLAG&&!dual_name)||(!(arj_flags&DUAL_NAME_FLAG)&&dual_name))    error(M_CANT_COMBINE_DUAL);   if((arj_flags&ANSICP_FLAG&&!ansi_codepage)||(!(arj_flags&ANSICP_FLAG)&&ansi_codepage))    error(M_ARCHIVE_CP_MISMATCH);   enc_type=ext_flags&0x0F;   if(ext_hdr_flags!=ENCRYPT_OLD&&enc_type!=ENCRYPT_OLD&&ext_hdr_flags!=enc_type)    error(M_WRONG_ENC_VERSION, (int)enc_type);   if(arj_nbr>=ARJ_NEWCRYPT_VERSION&&ext_hdr_flags==0&&enc_type!=ENCRYPT_OLD)   {    encryption_id=ENCID_GARBLE;    ext_hdr_flags=enc_type;   }   while(read_header(0, arc, name))   {    msg_cprintf(H_HL, M_ADDING);    msg_cprintf(H_HL|H_NFMT, M_FILENAME_FORM, filename);    write_index_entry(nullstr);    special_processing(CFA_NONE, arc);    rc++;   }   cfa_store(i, FLFLAG_PROCESSED);  }  fclose(arc); } return(rc);}#endif/* Inserts base directory into filespec */void add_base_dir(char *name){ #if SFX_LEVEL>=ARJ  char *tmp; #else  char tmp[FILENAME_MAX]; #endif if(target_dir[0]!='\0') {  #if SFX_LEVEL>=ARJ   tmp=malloc_str(name);   strcpy(name, target_dir);   strcat(name, tmp);   free(tmp);  #else   strcpy(tmp, name);   strcpy(name, target_dir);   strcat(name, tmp);  #endif }}/* Checks if the file can be unpacked */static int test_unpack_condition(char *name){

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -