Ticket #1010: UseMoveFileEx.diff

File UseMoveFileEx.diff, 1.5 KB (added by MattArsenault, 14 years ago)
  • lib/filesys.cpp

     
    529529    sprintf(cmd, "copy \"%s\" \"%s\"", orig, newf);
    530530    return system(cmd);
    531531#else
    532     // POSIX requires that shells run from an application will use the 
    533     // real UID and GID if different from the effective UID and GID. 
    534     // Mac OS 10.4 did not enforce this, but OS 10.5 does.  Since 
    535     // system() invokes a shell, it may not properly copy the file's 
    536     // ownership or permissions when called from the BOINC Client 
     532    // POSIX requires that shells run from an application will use the
     533    // real UID and GID if different from the effective UID and GID.
     534    // Mac OS 10.4 did not enforce this, but OS 10.5 does.  Since
     535    // system() invokes a shell, it may not properly copy the file's
     536    // ownership or permissions when called from the BOINC Client
    537537    // under sandbox security, so we copy the file directly.
    538538    FILE *src, *dst;
    539539    int m, n;
     
    568568
    569569static int boinc_rename_aux(const char* old, const char* newf) {
    570570#ifdef _WIN32
    571     boinc_delete_file(newf);
    572     if (MoveFileA(old, newf)) return 0;
     571    if (MoveFileExA(old, newf, MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH))
     572        return 0;
    573573    return GetLastError();
    574574#else
    575575    int retval = rename(old, newf);
     
    723723#ifdef _WIN32
    724724    getcwd(path, 256);
    725725#else
    726     char* p 
     726    char* p
    727727#ifdef __GNUC__
    728728      __attribute__ ((unused))
    729729#endif