MCPcopy Create free account
hub / github.com/NetHack/NetHack / update_file

Function update_file

sys/windows/windmain.c:724–753  ·  view source on GitHub ↗

update file copying if it does not exist or src is newer then dst */

Source from the content-addressed store, hash-verified

722
723/* update file copying if it does not exist or src is newer then dst */
724void
725update_file(const char *dst_folder, const char *dst_name,
726 const char *src_folder, const char *src_name, BOOL save_copy)
727{
728 char dst_path[MAX_PATH];
729 strcpy(dst_path, dst_folder);
730 strcat(dst_path, dst_name);
731
732 char src_path[MAX_PATH];
733 strcpy(src_path, src_folder);
734 strcat(src_path, src_name);
735
736 char save_path[MAX_PATH];
737 strcpy(save_path, dst_folder);
738 strcat(save_path, dst_name);
739 strcat(save_path, ".save");
740
741 if (!file_exists(src_path))
742 error("Unable to copy file '%s' as it does not exist", src_path);
743
744 if (!file_newer(src_path, dst_path))
745 return;
746
747 if (file_exists(dst_path) && save_copy)
748 CopyFileA(dst_path, save_path, FALSE);
749
750 BOOL success = CopyFileA(src_path, dst_path, FALSE);
751 if (!success)
752 error("Failed to update '%s' to '%s'", src_path, dst_path);
753}
754
755void
756copy_symbols_content(void)

Callers 15

copy_sysconf_contentFunction · 0.85
copy_config_contentFunction · 0.85
copy_hack_contentFunction · 0.85
saveoptvalsFunction · 0.85
save_killersFunction · 0.85
savenamesFunction · 0.85
save_wormFunction · 0.85
save_light_sourcesFunction · 0.85
save_regionsFunction · 0.85
save_timersFunction · 0.85
save_engravingsFunction · 0.85
save_exclusionsFunction · 0.85

Calls 3

file_newerFunction · 0.85
file_existsFunction · 0.70
errorFunction · 0.50

Tested by

no test coverage detected