📄 arj_arcv.c
字号:
int answer; /* Reply to overwrite/append queries */ int fr; struct timestamp ftime; unsigned long fsize; int volume_file; unsigned long append_pos; #if SFX_LEVEL>=ARJSFXV char *fname; /* Formatted name */ char arc_time[22], disk_time[22]; struct file_properties properties; #endif #if SFX_LEVEL>=ARJSFXV fname=format_filename(name); #endif if(!file_exists(name)) { #if SFX_LEVEL>=ARJSFXV if(freshen_criteria!=FC_NONE||continued_prevvolume) { #if SFX_LEVEL>=ARJ if(continued_prevvolume&&start_at_ext_pos&&ext_pos!=0L) { answer=yes_on_all_queries||skip_append_query; if(answer==0) { msg_cprintf(H_HL|H_NFMT, M_NOT_EXISTS, fname); answer=query_action(REPLY_YES, QUERY_APPEND, M_QUERY_CONTINUE); if(answer==1) { resume_position=0L; continued_prevvolume=0; create_subdir_tree(name, yes_on_all_queries, file_type); return(0); } } } #endif msg_cprintf(H_HL|H_NFMT, M_NOT_EXISTS, fname); return(1); } create_subdir_tree(name, yes_on_all_queries, file_type); return(0); #else if(freshen_criteria!=FC_NONE) { msg_cprintf(H_HL|H_NFMT, M_NOT_EXISTS, name); return(1); } else { create_subdir_tree(name, file_type); return(0); } #endif } #if SFX_LEVEL>=ARJSFXV fr=file_find(name, &properties); if(fr||properties.type!=ARJT_DIR&& properties.type!=ARJT_BINARY&& properties.type!=ARJT_UXSPECIAL) { msg_cprintf(H_ERR, M_CANTOPEN, name); msg_cprintf(0, (FMSG *)", "); return(2); } #endif if(new_files_only) { #if SFX_LEVEL>=ARJSFXV msg_cprintf(H_HL|H_NFMT, M_EXISTS, name); #else msg_cprintf(H_HL|H_NFMT, M_EXISTS, name); #endif return(1); } #if SFX_LEVEL>=ARJSFXV ts_store(&ftime, OS, properties.ftime); #else ts_store(&ftime, OS, file_getftime(name)); #endif if(!skip_ts_check) { #if SFX_LEVEL>=ARJ fsize=properties.fsize; volume_file=0; if(arj_flags&VOLUME_FLAG||arj_flags&EXTFILE_FLAG) { fsize=origsize; volume_file=1; } if(update_criteria==UC_NEW_OR_CRC||freshen_criteria==FC_CRC) { if(!volume_file&&fsize==origsize) { if(crc32_for_file(filename)==file_crc) { msg_cprintf(H_HL|H_NFMT, M_IS_SAME, fname); return(1); } } } else if(update_criteria==UC_NEW_OR_DIFFERENT||freshen_criteria==FC_DIFFERENT) { if(!ts_cmp(&ftime_stamp, &ftime)&&fsize==origsize) { msg_cprintf(H_HL|H_NFMT, M_IS_SAME, fname); return(1); } } else if(update_criteria==UC_NEW_OR_OLDER||freshen_criteria==FC_OLDER) { if(ts_cmp(&ftime, &ftime_stamp)<=0) { msg_cprintf(H_HL|H_NFMT, M_IS_SAME_OR_OLDER, fname); return(1); } } else if(update_criteria==UC_NEW_OR_NEWER||freshen_criteria==FC_EXISTING) { if(ts_cmp(&ftime, &ftime_stamp)>=0) { msg_cprintf(H_HL|H_NFMT, M_IS_SAME_OR_NEWER, fname); return(1); } } #else if(update_criteria!=UC_NONE&&freshen_criteria!=FC_NONE) { if(ts_cmp(&ftime, &ftime_stamp)>=0) { #if SFX_LEVEL>=ARJSFXV msg_cprintf(H_HL|H_NFMT, M_IS_SAME_OR_NEWER, fname); #else msg_cprintf(H_HL|H_NFMT, M_IS_SAME_OR_NEWER, name); #endif return(1); } } #endif } #if SFX_LEVEL>=ARJSFXV if(yes_on_all_queries&&!skip_ts_check&&continued_prevvolume&& (file_type==ARJT_TEXT||file_type==ARJT_BINARY)&&!ts_cmp(&ftime_stamp, &ftime)&& eh_find_pending(eh)!=NULL) { msg_cprintf(H_HL|H_NFMT, M_IS_NOT_SAME_DATE, fname); return(2); } #endif #if SFX_LEVEL>=ARJ if(serialize_exts!=EXT_NO_SERIALIZE) return(find_num_ext(name, serialize_exts)?2:0); if(arcmail_sw) return(find_arcmail_name(name)?2:0); #endif #if SFX_LEVEL>=ARJSFXV if(yes_on_all_queries) return(0); #else if(yes_on_all_queries||overwrite_existing) return(0); #endif /* Multivolume preprocessing */ #if SFX_LEVEL>=ARJSFXV #if SFX_LEVEL>=ARJ if(continued_prevvolume||start_at_ext_pos) #else if(continued_prevvolume) #endif { if(skip_append_query||(file_type!=ARJT_BINARY&&file_type!=ARJT_TEXT)) return(0); msg_cprintf(0, (!ts_cmp(&ftime_stamp, &ftime))?M_EXISTS:M_IS_NOT_SAME_DATE, fname); #if SFX_LEVEL>=ARJ append_pos=start_at_ext_pos?ext_pos:resume_position; #else append_pos=resume_position; #endif msg_sprintf(misc_buf, M_QUERY_APPEND, append_pos); return(query_action(REPLY_YES, QUERY_APPEND, (FMSG *)misc_buf)?0:-1); } #endif #if SFX_LEVEL>=ARJSFXV if(overwrite_existing /* ASR fix 31/03/2003: for new recursion order, skip directory overwrite prompt unless the user has specified "-2r". */ #if SFX_LEVEL>=ARJ ||(properties.type==ARJT_DIR&&!recursion_order) #endif ) return(0); timestamp_to_str(arc_time, &ftime_stamp); timestamp_to_str(disk_time, &ftime); msg_cprintf(H_HL|H_NFMT, M_ARJ_VS_DISK, origsize, arc_time+2, properties.fsize, disk_time+2); msg_cprintf(0, (ts_cmp(&ftime, &ftime_stamp)>=0)?M_IS_SAME_OR_NEWER:M_EXISTS, fname); return(query_action(REPLY_YES, QUERY_OVERWRITE, M_QUERY_OVERWRITE)?0:-1); #else msg_cprintf(0, (ts_cmp(&ftime_stamp, &ftime)>0)?M_EXISTS:M_IS_SAME_OR_NEWER, name); msg_cprintf(0, M_QUERY_OVERWRITE); return(query_action()?0:-1); #endif}#if SFX_LEVEL>=ARJSFXV/* Queries the user about renaming the file and performs neccessary checks */static int query_for_rename(char *name){ if(!query_action(REPLY_YES, QUERY_EXTRACT_RENAME, M_QUERY_EXTRACT_RENAME)) { skip_file(); errors++; return(0); } if(kbd_cleanup_on_input) fetch_keystrokes(); msg_cprintf(0, M_ENTER_NEW_FILENAME); if(read_line(name, FILENAME_MAX)==0) { skip_file(); errors++; return(0); } #if SFX_LEVEL>=ARJ if(translate_unix_paths) unix_path_to_dos(name); #endif case_path(name); if(test_unpack_condition(name)) { skip_file(); errors++; return(0); } else return(1);}#endif/* Checks if the OS and current conditions allow unpacking */#if SFX_LEVEL>=ARJstatic int test_unpack_env(int disk_touched)#elsestatic int test_unpack_env()#endif{ /* The text below is NOT a typo, this check is really used in ARJSFXV (since headers may be damaged, and so on...) */ #if SFX_LEVEL>=ARJSFXV if(arj_x_nbr>EXTR_LEVEL) { msg_cprintf(H_HL|H_NFMT, M_UNKNOWN_VERSION, (int)arj_x_nbr); skip_file(); return(-1); } #endif if(file_garbled&&!garble_enabled) { #if SFX_LEVEL>=ARJSFXV msg_cprintf(0, M_FILE_IS_GARBLED); #else msg_cprintf(0, M_FILE_IS_GARBLED); #endif skip_file(); return(-1); } #if SFX_LEVEL>=ARJSFXV #if SFX_LEVEL>=ARJ if(method>MAXMETHOD&&method<8||method==MAXMETHOD&&arj_nbr==1) #else if(method>3) #endif { /* ARJ 0.xx -m4 is not supported */ msg_cprintf(H_HL|H_NFMT, M_UNKNOWN_METHOD, (int)method); skip_file(); return(-1); } #if SFX_LEVEL>=ARJ if(file_type!=ARJT_BINARY&&file_type!=ARJT_TEXT&&file_type!=ARJT_DIR&& file_type!=ARJT_COMMENT&&file_type!=ARJT_LABEL&&file_type!=ARJT_CHAPTER&& file_type!=ARJT_UXSPECIAL) #else if(file_type!=ARJT_BINARY&&file_type!=ARJT_TEXT&&file_type!=ARJT_DIR&& file_type!=ARJT_LABEL&&file_type!=ARJT_UXSPECIAL) #endif { msg_cprintf(H_HL|H_NFMT, M_UNKNOWN_FILE_TYPE, file_type); skip_file(); return(-1); } #endif /* Check for ability to extract Windows 95 LFNs */ #if TARGET==DOS #if SFX_LEVEL>=ARJ if(disk_touched&&(host_os==OS_WIN95||host_os==OS_WINNT)) { if(lfn_supported==LFN_NOT_SUPPORTED&&lfn_mode<=LFN_NONE) { msg_cprintf(0, M_REQUIRES_WIN95); skip_file(); return(-1); } } #else if(host_os==OS_WIN95&&lfn_supported==LFN_NOT_SUPPORTED&&!process_lfn_archive) { #if SFX_LEVEL>=ARJSFXV msg_cprintf(0, M_REQUIRES_WIN95); #else msg_cprintf(0, M_REQUIRES_WIN95); #endif skip_file(); return(-1); } #endif #endif return(0);}/* Unpacks a single file (NOT the main extraction routine; see below) */static void unpack_file(int action){ unsigned long st_ticks=0; #if SFX_LEVEL>=ARJSFXV uncompsize=origsize; #endif /* Verbose display option is missing from ARJSFXV but is supported by ARJSFX */ #if SFX_LEVEL==ARJSFX if(verbose_display) msg_cprintf(H_HL|H_NFMT, M_N_BYTES, origsize); #endif crc32term=CRC_MASK; #if SFX_LEVEL>=ARJSFXV if(debug_enabled&&strchr(debug_opt, 't')!=NULL) st_ticks=get_ticks(); #endif#if SFX_LEVEL>=ARJSFXV if(file_type==ARJT_BINARY||file_type==ARJT_TEXT)#else if(file_type!=ARJT_DIR&&file_type!=ARJT_UXSPECIAL)#endif { #if SFX_LEVEL>=ARJ if(hollow_mode==HM_CRC||method==9) hollow_decode(action); else if(method!=8&&test_archive_crc!=TC_ATTRIBUTES) { if(method==0) unstore(action); else if(method>=1&&method<=3) decode(action); else if(method==4) decode_f(action); } #else #if SFX_LEVEL<=ARJSFX garble_init(password_modifier); uncompsize=origsize; #endif if(method==0) unstore(action); else decode(action); #endif } display_indicator(uncompsize); #if SFX_LEVEL>=ARJSFXV skip_compdata(); #endif #if SFX_LEVEL>=ARJSFXV if(debug_enabled) { #if SFX_LEVEL>=ARJ if(strchr(debug_opt, 'k')!=NULL) compsize=0L; #endif if(strchr(debug_opt, 't')!=NULL) msg_cprintf(H_HL|H_NFMT, M_N_TICKS, st_ticks=get_ticks()-st_ticks); } #endif #if SFX_LEVEL<=ARJSFX if((crc32term^CRC_MASK)==file_crc) msg_cprintf(0, M_OK); else { msg_cprintf(H_ALERT, M_CRC_ERROR); errors++; } #endif}/* Test/search routine */#if SFX_LEVEL>=ARJint unpack_validation(int cmd)#elseint unpack_validation()#endif{ int action; #if SFX_LEVEL>=ARJSFXV int found; /* 1 if the file is present */ int errflag; int nf_error; /* Non-fatal error */ int pattern; /* Current search pattern */ #endif #if SFX_LEVEL>=ARJ struct file_properties properties; #endif #if SFX_LEVEL>=ARJ found=1; errflag=nf_error=0; pattern_found=0; identical_filedata=1; if(test_unpack_env(0)) return(0); #else if(test_unpack_env()) return(0); #endif #if SFX_LEVEL>=ARJ if(cmd==ARJ_CMD_WHERE) { action=BOP_SEARCH; msg_sprintf(misc_buf, M_SEARCHING, filename); if(search_mode==SEARCH_DEFAULT||search_mode==SEARCH_SHOW_NAMES) alltrim(misc_buf); if(search_mode<=SEARCH_BRIEF) { msg_cprintf(0, (FMSG *)strform, misc_buf); if(search_mode==SEARCH_DEFAULT) msg_cprintf(0, (FMSG *)lf); if(search_mode==SEARCH_BRIEF) msg_cprintf(0, (FMSG *)cr); } for(pattern=0; pattern<SEARCH_STR_MAX; search_occurences[pattern++]=0); reserve_size=0; } else { action=BOP_NONE; msg_cprintf(H_HL|H_NFMT, M_TESTING, format_filename(filename)); if(!verbose_display) msg_cprintf(0, (FMSG *)vd_space); else { nputlf(); msg_cprintf(H_HL|H_NFMT, M_N_BYTES, origsize); } if(test_archive_crc>=TC_CRC_AND_CONTENTS) { if(test_archive_crc==TC_CRC_AND_CONTENTS||total_chapters==0||(unsigned int)ext_flags<=total_chapters&&(unsigned int)chapter_number>=total_chapters) { if(test_archive_crc!=TC_ADDED_FILES||flist_is_in_archive(&flist_main, filename)) { if(test_archive_crc!=TC_ADDED_FILES||total_chapters==0||(unsigned int)chapter_number==total_chapters) { if(method==8||test_archive_crc==TC_ATTRIBUTES) { action=BOP_COMPARE; if(file_find(filename, &properties)) found=0; } else { if(file_type==ARJT_BINARY||file_type==ARJT_TEXT) { action=BOP_COMPARE; if((tstream=file_open(filename, read_perms[file_type%2]))==NULL) { action=BOP_NONE; found=0; errflag=1; if((ignore_open_errors==IAE_ACCESS&&errno==EACCES)|| (ignore_open_errors==IAE_NOTFOUND&&errno==ENOENT)|| (ignore_open_errors==IAE_ALL&&(errno==EACCES||errno==ENOENT))) errflag=0; } else smart_seek(resume_position, tstream); } else if(file_type==ARJT_DIR) { if(!is_directory(filename)) { errflag=1; found=0; } } } } } } } } #else action=BOP_NONE; #if SFX_LEVEL>=ARJSFXV msg_cprintf(H_HL|H_NFMT, M_TESTING, format_filename(filename)); msg_cprintf(0, (FMSG *)vd_space); #else msg_cprintf(H_HL|H_NFMT, M_TESTING, filename); #endif #endif atstream=NULL; #if SFX_LEVEL>=ARJSFXV if(file_garbled) garble_init(password_modifier); #endif unpack_file(action); #if SFX_LEVEL>=ARJ if(!found) { msg_cprintf(0, M_NOT_FOU
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -