Hi ShDancer,
I haven't tried the virtual disk thing but I did notice that your little procedure is not the correct way to create a sparce file.
Example, use this command to call your procedure:
Code:
makeSparse("test1.txt", 100*1024*1024)
Then check the properties of the created file...
Size: 100 MB (104,857,600 bytes)
Size on Disk: 100 MB (104,857,600 bytes)
Now try this procedure:
Code:
#FSCTL_SET_SPARSE=$900C4
Procedure MKSparce(FileName.s,FileSize)
hFile=CreateFile_(FileName,#GENERIC_READ|#GENERIC_WRITE,#FILE_SHARE_READ|#FILE_SHARE_WRITE,0,#CREATE_NEW,#FILE_FLAG_NO_BUFFERING,0)
If FileHandle<>#INVALID_HANDLE_VALUE
If DeviceIoControl_(hFile,#FSCTL_SET_SPARSE,0,0,0,0,@Bytes,0)
If SetFilePointer_(hFile,FileSize,0,#FILE_BEGIN)
SetEndOfFile_(hFile)
Result=1
EndIf
EndIf
CloseHandle_(hFile)
EndIf
ProcedureReturn Result
EndProcedure
And use this command to call the new procedure:
Code:
MKSparse("test2.txt", 100*1024*1024)
Check the file size of the new file...
Size: 100 MB (104,857,600 bytes)
Size on Disk: 16 KB (16,384 bytes) <--- 16KB !!!
A true sparce file makes the OS think it is 100MB total but actually takes up only 16kb on the hard drive. Much more efficient if there is only a small amount of data stored in it when it's being used as a virtual disk.
