Ticket #6822: operations.patch

File operations.patch, 1.9 KB (added by Antony Polukhin, 11 years ago)

Patch for trunk version of libs/filesystem/src/operations.cpp

  • operations.cpp

     
    596596      ::GetFullPathNameW(src.c_str(), static_cast<DWORD>(len), buf, p));
    597597  }
    598598
    599   fs::file_status process_status_failure(const path& p, error_code* ec)
     599  fs::file_status process_status_failure(const path& p, int errval, error_code* ec)
    600600  {
    601     int errval(::GetLastError());
     601    // Some compilers can call ::SetLastError(0) just before process_status_failure
     602    // is called. It is much safer to call ::GetLastError() in a function,
     603    // that triggered a failure.
     604    //int errval(::GetLastError());   
    602605    if (ec != 0)                             // always report errval, even though some
    603606      ec->assign(errval, system_category());   // errval values are not status_errors
    604607
     
    623626    DWORD attr(::GetFileAttributesW(p.c_str()));
    624627    if (attr == 0xFFFFFFFF)
    625628    {
    626       return process_status_failure(p, ec).type();
     629      return process_status_failure(p, ::GetLastError(), ec).type();
    627630    }
    628631
    629632    if (ec != 0) ec->clear();
     
    16161619    DWORD attr(::GetFileAttributesW(p.c_str()));
    16171620    if (attr == 0xFFFFFFFF)
    16181621    {
    1619       return process_status_failure(p, ec);
     1622      return process_status_failure(p, ::GetLastError(), ec);
    16201623    }
    16211624
    16221625    //  reparse point handling;
     
    16351638            0)); // hTemplateFile
    16361639      if (h.handle == INVALID_HANDLE_VALUE)
    16371640      {
    1638         return process_status_failure(p, ec);
     1641        return process_status_failure(p, ::GetLastError(), ec);
    16391642      }
    16401643
    16411644      if (!is_reparse_point_a_symlink(p))
     
    16991702    DWORD attr(::GetFileAttributesW(p.c_str()));
    17001703    if (attr == 0xFFFFFFFF)
    17011704    {
    1702       return process_status_failure(p, ec);
     1705      return process_status_failure(p, ::GetLastError(), ec);
    17031706    }
    17041707
    17051708    if (ec != 0) ec->clear();