WofSetFileDataLocation function (wofapi.h)

Used to change a file from being backed by a physical file to one backed by a system data provider.

Syntax

HRESULT WofSetFileDataLocation(
  [in] HANDLE FileHandle,
  [in] ULONG  Provider,
  [in] PVOID  ExternalFileInfo,
  [in] ULONG  Length
);

Parameters

[in] FileHandle

A handle to a file opened with CreateFile or a similar API.

[in] Provider

Indicates which provider is backing this file. Currently defined providers are:

WOF_PROVIDER_WIM Indicates that the data for the file should be obtained from a WIM file. On access, data is transparently extracted from the WIM file and provided to applications. If the file contents are modified, data is transparently decompressed and the file is restored to the same physical form it had if this API were not used.
WOF_PROVIDER_FILE Indicates that the data for the file should be compressed and stored with the file itself. On access, data is transparently decompressed and provided to applications. If the file contents are modified, data is transparently decompressed and the file is restored to the same physical form it had if this API were not used. This provider requires Windows 10.

[in] ExternalFileInfo

Provides data specific to the specified provider. Data structures for each defined provider are:

WOF_PROVIDER_WIM WIM_EXTERNAL_FILE_INFO
WOF_PROVIDER_FILE WOF_FILE_COMPRESSION_INFO

[in] Length

Specifies the length of provider specific data, in bytes. This should correspond to the structures defined above:

WOF_PROVIDER_WIM sizeof(WIM_EXTERNAL_FILE_INFO)
WOF_PROVIDER_FILE sizeof(WOF_FILE_COMPRESSION_INFO)

Return value

This function returns an HRESULT indicating success or the reason for failure.

Remarks

When using WOF_PROVIDER_FILE, the operation may fail with ERROR_COMPRESSION_NOT_BENEFICIAL. This indicates that an attempt was made to compress the data, but no disk space was saved, so the file was not compressed. For most applications, this can be treated as a success condition.

Requirements

Requirement Value
Target Platform Windows
Header wofapi.h
Library Wofutil.lib
DLL Wofutil.dll

See also

FSCTL_SET_EXTERNAL_BACKING