| 696 | } |
| 697 | |
| 698 | BOOL GetFileClusterSize(const std::wstring &strFilename, PLARGE_INTEGER lpRealFileSize) |
| 699 | { |
| 700 | DWORD dwClusterSize; |
| 701 | |
| 702 | LARGE_INTEGER lFileSize; |
| 703 | BOOL bRet = GetFileSizeEx(strFilename.c_str(), &lFileSize); |
| 704 | |
| 705 | if (!bRet) |
| 706 | { |
| 707 | return FALSE; |
| 708 | } |
| 709 | |
| 710 | TCHAR szRoot[MAX_PATH]; |
| 711 | HRESULT hr = StringCchCopy(szRoot, SIZEOF_ARRAY(szRoot), strFilename.c_str()); |
| 712 | |
| 713 | if (FAILED(hr)) |
| 714 | { |
| 715 | return FALSE; |
| 716 | } |
| 717 | |
| 718 | bRet = PathStripToRoot(szRoot); |
| 719 | |
| 720 | if (!bRet) |
| 721 | { |
| 722 | return FALSE; |
| 723 | } |
| 724 | |
| 725 | bRet = GetClusterSize(szRoot, &dwClusterSize); |
| 726 | |
| 727 | if (!bRet) |
| 728 | { |
| 729 | return FALSE; |
| 730 | } |
| 731 | |
| 732 | if ((lFileSize.QuadPart % dwClusterSize) != 0) |
| 733 | { |
| 734 | /* The real size is the logical file size rounded up to the end of the |
| 735 | nearest cluster. */ |
| 736 | lFileSize.QuadPart += dwClusterSize - (lFileSize.QuadPart % dwClusterSize); |
| 737 | } |
| 738 | |
| 739 | *lpRealFileSize = lFileSize; |
| 740 | |
| 741 | return TRUE; |
| 742 | } |
| 743 | |
| 744 | void NFileOperations::DeleteFileSecurely( |
| 745 | const std::wstring &strFilename, OverwriteMethod_t uOverwriteMethod) |
no test coverage detected