Sidebar

Using Directory Opus
Configuration
Programming
Reference Section
reference:plugins:vfs_plugins:vfs_getnextfile

VFS_GetNextFile(
     HANDLE:hVFSData,
     HANDLE:hOutOfOrderData,
     LPWSTR:lpszFilePath,
     UINT:cchFileMax,
     LPSTREAM*:ppFileStream,
     WIN32_FIND_DATA*:pfdFileInfo,
     DWORD*:pdwDataValid,
     LONG*:plErrCode,
     LPWSTR:pszErrMsg,
     UINT:cchErrMsgMax
)
→ BOOL

Arguments

hVFSData

[in] The handle to the namespace instance data

hOutOfOrderData

[in] The handle returned by VFS_BeginOutOfOrder

lpszFilePath

[out] Buffer to receive the path of the file

cchFileMax

[in] Size of the lpszFilePath buffer in characters

ppFileStream

[out] Receives a stream for the file

pfdFileInfo

[out] Receives information about the file. Use pdwDataValid to indicate which fields are valid. Ignored if the function returns FALSE

pdwDataValid

[out] Flags indicating which data is valid

VFSGNF_DataValid_FilePathlpszFilePath
VFSGNF_DataValid_AttrpfdFileInfo->dwFileAttributes
VFSGNF_DataValid_CreateTimepfdFileInfo->ftCreationTime
VFSGNF_DataValid_AccessTimepfdFileInfo->ftLastAccessTime
VFSGNF_DataValid_WriteTimepfdFileInfo->ftLastWriteTime
VFSGNF_DataValid_SizepfdFileInfo->nFileSizeHigh and pfdFileInfo->nFileSizeLow
VFSGNF_DataValid_FileNamepfdFileInfo->cFileName
VFSGNF_DataValid_AllAll of the above

plErrCode

[out] Receives an error code if the function returns FALSE

pszErrMsg

[out] Buffer for a custom error message. Set *plErrCode to -1 to use it

cchErrMsgMax

[in] Size of the pszErrMsg buffer in characters

Return value

Return TRUE if the next file was retrieved successfully, or FALSE if there was an error or there are no more files.

Description

The VFS_GetNextFile function is called to retrieve the next file of an out-of-order operation.

If VFS_GetNextFile returns TRUE, at least VFSGNF_DataValid_FilePath must be set in *pdwDataValid.

If VFS_GetNextFile returns FALSE:

  • If all files are complete, set *plErrCode to ERROR_NO_MORE_FILES. This is the normal way to end the enumeration.
  • If you have an error for a file, or for the overall operation, set *plErrCode to the error code, or set *plErrCode to -1 and store a custom error message in pszErrMsg.
  • If possible, still return the file path in lpszFilePath. It is used to display the error message, and to mark the file as "failed" so it does not get deselected. If the failure happens before you know which path you are dealing with (or it is a general failure for the whole archive), leave lpszFilePath empty. The WIN32_FIND_DATA structure is ignored in error cases.
  • You must not set VFSGNF_DataValid_FilePath if you leave lpszFilePath empty, or set it to something other than one of the file paths you were given. For example, you may report an error for the entire archive and set lpszFilePath to the archive path so it appears in the error message, or you may be reporting an error caused by lpszFilePath being too small for the path. In both cases VFSGNF_DataValid_FilePath must not be set.
  • If VFSGNF_DataValid_FilePath is not set, lpszFilePath is only used to generate the error message. The message usually only includes the filename, not the full path, so you can fill in just the name if you like (for example, if the full path is too long for the buffer). If the name by itself is also too long, truncate it.

Errors reading from the stream should be saved in the stream object and made available through the IOpusOOOStreamError interface, which Opus looks for on the stream if its methods fail (the ISequentialStream::Read method should return E_FAIL or another error code). The interface has three methods:

struct IOpusOOOStreamError : public IUnknown
{
    virtual HRESULT STDMETHODCALLTYPE GetError(LONG* lErrCode) = 0;
    virtual HRESULT STDMETHODCALLTYPE GetErrorMsg(LPWSTR pszErrBuf, ULONG cchErrBuf) = 0;
    virtual HRESULT STDMETHODCALLTYPE ClearError() = 0;
};

Its interface ID is IID_IOpusOOOStreamError.

VFS_GetLastError is never used to report errors relating to the out-of-order functions.

See also VFS_BeginOutOfOrder, VFS_EndOutOfOrder and the VFSCAPABILITY_OUTOFORDER capability flag.

This function was added in Directory Opus 10 (VFSPLUGINVERSION 4).