I could not make sparsing to work on my desktop (Brand new Dell PC with
factory installed WIN2K on NTFS). It works on other m/c. Could you tell me
what will be the problem.
Here is the code,
TCHAR szPathName = __TEXT(“C:\TestSparse”);
DWORD dwBytes;
BOOL bResult;
HANDLE hFile;
BY_HANDLE_FILE_INFORMATION bhfi;
//Verify c:\ supports sparse or not?
if(GetVolumeInformation(“C:\”, NULL, 0, NULL, NULL, &dwBytes, NULL,
0))
{
bResult = (dwBytes == 0xfffffff) ? FALSE : dwBytes &
FILE_SUPPORTS_SPARSE_FILES;
if(!bResult) { DisplayErrorMsg(); return; }
}
//create new file
hFile = CreateFile(szPathName, GENERIC_READ | GENERIC_WRITE, 0,
NULL, CREATE_ALWAYS, 0, NULL);
if(hFile == INVALID_HANDLE_VALUE){ DisplayErrorMsg(); return; }
//set sparse for created file
dwBytes = 0;
bResult = DeviceIoControl(hFile, FSCTL_SET_SPARSE, NULL, 0, NULL, 0,
&dwBytes, NULL);
if(!bResult) { DisplayErrorMsg(); CloseHandle(hFile); return; }
//verify the file whether it is sparse one or not?
GetFileInformationByHandle(hFile, &bhfi);
bResult = bhfi.dwFileAttributes & FILE_ATTRIBUTE_SPARSE_FILE;
if(!bResult) { DisplayErrorMsg(); CloseHandle(hFile); return; }
//make it bigger (32GB) to look, but actual size on disk is zero
LONG lDist = 8;
SetFilePointer(hFile, 0, &lDist, FILE_BEGIN);
SetEndOfFile(hFile);
CloseHandle(hFile);
You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com