VFS_FindFirstFile(
     HANDLE:hVFSData,
     LPVFSFUNCDATA:lpFuncData,
     LPTSTR:lpszPath,
     LPWIN32_FIND_DATA:lpwfdData,
     HANDLE:hAbortEvent
)
→ HANDLE

Arguments

hVFSData

[in] The handle to the namespace instance data

lpFuncData

[in] unused

lpszPath

[in] The full pathname of the item to retrieve information for, or a path plus wildcard pattern to examine all matching items.

lpwfdData

[out] Pointer to a WIN32_FIND_DATA into which you place information about the first matching item

hAbortEvent

[in] May be NULL, otherwise provides a Windows event that you can use to detect when the user wants to abort a lengthy operation

Return value

If the operation succeeds, you must allocate and return a data structure that will passed to the VFS_FindNextFile function to continue the enumeration of all matching items. If the operation fails you should return NULL.

Description

The VFS_FindFirstFile function is called to obtain information about a single file or folder, or about all items in a directory that match a wildcard pattern.

You should check the final path component of lpszPath to see if it is an actual filename, or a wildcard pattern. Currently Opus does not use wildcard patterns other than "*" - that is, either Opus wants just a single file, or it wants every file in the directory.

You should place as much information as possible about the first (or only) matching file into lpwfdData and return a data structure cast to a HANDLE that Opus can use to continue the enumeration.

If Opus only asks for information about a single file there is no need to allocate a data structure - in this case you could just return TRUE cast to a HANDLE, as long as you check for this value in VFS_FindNextFile and VFS_FindClose. If Opus supplies a wildcard pattern then the structure pointed to by the handle you return must provide enough information for your VFS_FindNextFile function to continue the enumeration of all items in the directory.

If hAbortEvent is non-NULL it is a windows event handle that you can use to check if the user wants to abort the enumeration. You should store this handle in your data structure so you can check it in your VFS_FindNextFile function. You can check for the abort signal with the following code:

if ( hAbortEvent && WaitForSingleObject( hAbortEvent, 0 ) == WAIT_OBJECT_0 )
{
    // aborted
}