CcSetFileSizes function (ntifs.h)

The CcSetFileSizes routine updates the cache maps and section object for a cached file whose size has changed. Use CcSetFileSizesEx instead since it provides an NTSTATUS return code along with better guidance for error handling.

Syntax

void CcSetFileSizes(
  [in] PFILE_OBJECT   FileObject,
  [in] PCC_FILE_SIZES FileSizes
);

Parameters

[in] FileObject

Pointer to a file object for the cached file.

[in] FileSizes

Pointer to a CC_FILE_SIZES structure containing the new file size information.

Return value

None

Remarks

File systems must call CcSetFileSizesEx or CcSetFileSizes to update the cache manager data structures whenever one of the following changes is made to a cached file:

  • Its allocation size is increased.

  • Its valid data length is decreased.

  • Its valid data length is increased by a non-cached I/O operation.

  • Its file size is increased or decreased.

If any failure occurs, CcSetFileSizes raises a status exception for that particular failure. For example, if a pool allocation failure occurs, CcSetFileSizes raises a STATUS_INSUFFICIENT_RESOURCES exception. Therefore, to gain control if a failure occurs, the driver should wrap the call to CcSetFileSizes in a try-except or try-finally statement.

The file system must ensure that the cache map is valid and will remain so for the duration of this call.

To cache a file, use CcInitializeCacheMap.

To get the size of the cached file, pass FileObject to CcGetFileSizePointer.

Requirements

Requirement Value
Target Platform Universal
Header ntifs.h (include Ntifs.h)
Library NtosKrnl.lib
DLL NtosKrnl.exe

See also

CcInitializeCacheMap

CcSetFileSizesEx