From 158510e04615f8422e6d3e7c2e5f06e7b0e76d26 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 22 Aug 2002 21:44:00 +0000 Subject: [PATCH] win rename svn path=/trunk/boinc/; revision=367 --- apps/concat_slow.C | 4 +--- apps/uc_cpu.C | 2 +- apps/uc_slow.C | 2 +- client/client_state.C | 4 ++-- client/cs_scheduler.C | 4 ++-- client/filesys.C | 7 +++++++ client/filesys.h | 1 + 7 files changed, 15 insertions(+), 9 deletions(-) diff --git a/apps/concat_slow.C b/apps/concat_slow.C index b05a6ce44c..c6c0ff9127 100644 --- a/apps/concat_slow.C +++ b/apps/concat_slow.C @@ -40,13 +40,11 @@ int do_checkpoint(MFILE& mf, int filenum, int nchars ) { fprintf(stderr, "APP: concat_slow checkpointing\n"); - // hopefully atomic part starts here retval = mf.flush(); if (retval) return retval; boinc_resolve_filename( CHECKPOINT_FILE, res_name2 ); - retval = rename(resolved_name, res_name2); + retval = boinc_rename(resolved_name, res_name2); if (retval) return retval; - // hopefully atomic part ends here return 0; } diff --git a/apps/uc_cpu.C b/apps/uc_cpu.C index 9f59926dd6..3f8c718bb1 100644 --- a/apps/uc_cpu.C +++ b/apps/uc_cpu.C @@ -52,7 +52,7 @@ int do_checkpoint(MFILE& mf, int nchars) { retval = mf.flush(); if (retval) return retval; boinc_resolve_filename( CHECKPOINT_FILE, res_name2 ); - retval = rename(resolved_name, res_name2); + retval = boinc_rename(resolved_name, res_name2); if (retval) return retval; // hopefully atomic part ends here diff --git a/apps/uc_slow.C b/apps/uc_slow.C index 4dc11b6ce7..ba0a33dab8 100644 --- a/apps/uc_slow.C +++ b/apps/uc_slow.C @@ -46,7 +46,7 @@ int do_checkpoint(MFILE& mf, int nchars) { retval = mf.flush(); if (retval) return retval; boinc_resolve_filename( CHECKPOINT_FILE, res_name2 ); - retval = rename(resolved_name, res_name2); + retval = boinc_rename(resolved_name, res_name2); if (retval) return retval; // hopefully atomic part ends here diff --git a/client/client_state.C b/client/client_state.C index 414d6e18af..cbac3800bc 100644 --- a/client/client_state.C +++ b/client/client_state.C @@ -379,7 +379,7 @@ int CLIENT_STATE::write_state_file() { ); fprintf(f, "\n"); fclose(f); - retval = rename(STATE_FILE_TEMP, STATE_FILE_NAME); + retval = boinc_rename(STATE_FILE_TEMP, STATE_FILE_NAME); if (log_flags.state_debug) { printf("Done writing state file\n"); } @@ -393,9 +393,9 @@ int CLIENT_STATE::write_state_file() { int CLIENT_STATE::write_state_file_if_needed() { int retval; if (client_state_dirty) { + client_state_dirty = false; retval = write_state_file(); if (retval) return retval; - client_state_dirty = false; } return 0; } diff --git a/client/cs_scheduler.C b/client/cs_scheduler.C index dc8faace4d..95b4ed970c 100644 --- a/client/cs_scheduler.C +++ b/client/cs_scheduler.C @@ -366,8 +366,8 @@ void CLIENT_STATE::handle_scheduler_reply( fclose(f); if (new_prefs->looks_reasonable(*project)) { make_prefs_backup_name(*prefs, prefs_backup); - rename(PREFS_FILE_NAME, prefs_backup); - rename(PREFS_TEMP_FILE_NAME, PREFS_FILE_NAME); + boinc_rename(PREFS_FILE_NAME, prefs_backup); + boinc_rename(PREFS_TEMP_FILE_NAME, PREFS_FILE_NAME); for (i=0; iprojects.size(); i++) { pp = new_prefs->projects[i]; sp = lookup_project(pp->master_url); diff --git a/client/filesys.C b/client/filesys.C index 85c3bf1f6b..0f3a2835c2 100644 --- a/client/filesys.C +++ b/client/filesys.C @@ -254,3 +254,10 @@ double dir_size(char* dirpath) { dir_close(dirp); return cur_size; } + +int boinc_rename(char* old, char* newf) { +#ifdef _WIN32 + unlink(newf); +#endif + return rename(old, newf); +} diff --git a/client/filesys.h b/client/filesys.h index 8f8d706cfd..a94b203db5 100644 --- a/client/filesys.h +++ b/client/filesys.h @@ -38,3 +38,4 @@ extern int file_size(char*, int&); extern int boinc_link(char *existing, char *new_link); extern int clean_out_dir(char*); extern double dir_size(char* dirpath); +extern int boinc_rename(char* old, char* newf);