The SetEndOfFile function can be used to truncate or extend a file. If the file is extended, the contents of the file between the old end of the file and the new end of the file are not defined.
既然说增加的文件长度,又说增加的内容是不确定的,可以理解是直接分配1G的内容而并不写入1G的数据,所以应该是瞬间完成。
If you set FileInformationClass to FileEndOfFileInformation, and the EndOfFile member of FILE_END_OF_FILE_INFORMATION specifies an offset beyond the current end-of-file mark, ZwSetInformationFile extends the file and pads the extension with zeros.
File system filter drivers can find it useful to set a valid data length in the following scenarios:
When creating large files where performance is an issue. This avoids the time it takes to fill the file with zeros when the file is created or extended.
可以设置文件有效数据的长度。一般在一下情况下使用。当创建一个大文件而又要求效率的时候,这个功能可以避免对文件进行0数据的填充。