1
1
/* ***************************** Module Header ******************************\
2
2
* Module Name: CppSparseFile.cpp
3
3
* Project: CppSparseFile
4
+ * URL: http://code.msdn.microsoft.com/windowsapps/CppSparseFile-7f28156b
4
5
* Copyright (c) Microsoft Corporation.
5
6
*
6
7
* CppSparseFile demonstrates the common operations on sparse files. A sparse
@@ -238,83 +239,3 @@ BOOL GetSparseRanges(LPCTSTR lpFileName)
238
239
CloseHandle (hFile);
239
240
return TRUE ;
240
241
}
241
- //
242
- //
243
- // int _tmain(int argc, _TCHAR* argv[])
244
- // {
245
- // /////////////////////////////////////////////////////////////////////////
246
- // // Determine if the volume support sparse streams.
247
- // //
248
- //
249
- // if (!VolumeSupportsSparseFiles(L"C:\\"))
250
- // {
251
- // wprintf(L"Volume %s does not support sparse streams\n", L"C:\\");
252
- // return 1;
253
- // }
254
- //
255
- //
256
- // /////////////////////////////////////////////////////////////////////////
257
- // // Create a sparse file.
258
- // //
259
- //
260
- // LPCWSTR lpFileName = L"SparseFile.tmp";
261
- // wprintf(L"Create sparse file: %s\n", lpFileName);
262
- //
263
- // HANDLE hSparseFile = CreateSparseFile(lpFileName);
264
- // if (hSparseFile == INVALID_HANDLE_VALUE)
265
- // {
266
- // wprintf(L"CreateFile failed w/err 0x%08lx\n", GetLastError());
267
- // return 1;
268
- // }
269
- //
270
- // // Write a large block of data
271
- //
272
- // const DWORD dwBlockLength = 512 * 1024; // 512KB
273
- // BYTE* lpBlock = new BYTE[dwBlockLength];
274
- // for (DWORD i = 0; i < dwBlockLength; i++)
275
- // {
276
- // lpBlock[i] = 0xFF;
277
- // }
278
- // DWORD dwBytesWritten;
279
- // WriteFile(hSparseFile, lpBlock, dwBlockLength, &dwBytesWritten, NULL);
280
- // delete[] lpBlock;
281
- //
282
- // // Set some sparse ranges in the block
283
- //
284
- // SetSparseRange(hSparseFile, 0, 64 * 1024 /*64KB*/);
285
- // SetSparseRange(hSparseFile, 128 * 1024, 128 * 1024);
286
- //
287
- // // Set sparse block at the end of the file
288
- //
289
- // // 1GB sparse zeros are extended to the end of the file
290
- // SetFilePointer(hSparseFile, 0x40000000 /*1GB*/, NULL, FILE_END);
291
- // SetEndOfFile(hSparseFile);
292
- //
293
- // // Flush and close the file
294
- // CloseHandle(hSparseFile);
295
- //
296
- //
297
- // /////////////////////////////////////////////////////////////////////////
298
- // // Determine if a file is sparse.
299
- // //
300
- //
301
- // BOOL fIsSparse = IsSparseFile(lpFileName);
302
- // wprintf(L"The file is%s sparse\n", fIsSparse ? L"" : L" not");
303
- //
304
- //
305
- // /////////////////////////////////////////////////////////////////////////
306
- // // Get file size.
307
- // //
308
- //
309
- // GetSparseFileSize(lpFileName);
310
- //
311
- //
312
- // /////////////////////////////////////////////////////////////////////////
313
- // // Query the sparse file layout.
314
- // //
315
- //
316
- // GetSparseRanges(lpFileName);
317
- //
318
- //
319
- // return 0;
320
- // }
0 commit comments