MCPcopy Create free account
hub / github.com/derceg/explorerplusplus / GetFileClusterSize

Function GetFileClusterSize

Explorer++/Helper/FileOperations.cpp:698–742  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

696}
697
698BOOL 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
744void NFileOperations::DeleteFileSecurely(
745 const std::wstring &strFilename, OverwriteMethod_t uOverwriteMethod)

Callers 1

DeleteFileSecurelyMethod · 0.85

Calls 3

GetFileSizeExFunction · 0.85
GetClusterSizeFunction · 0.85
c_strMethod · 0.80

Tested by

no test coverage detected