FindFirstByQuery Method
Searches for the first file or directory whose file tags match the specified query.
Syntax
public long findFirstByQuery(String directory, String query, int flags);
Remarks
This method initiates a search operation within the specified Directory for files and subdirectories whose typed file tags match the specified Query. If there are any matching files or directories, then a search operation handle pointing to the first result is returned. If there are no matching files or directories, then -1 is returned.
To obtain information about a search result, pass the returned search handle to the following methods:
- GetSearchResultAttributes
- GetSearchResultCreationTime
- GetSearchResultFullName
- GetSearchResultLastAccessTime
- GetSearchResultLinkDestination
- GetSearchResultMetadataSize
- GetSearchResultModificationTime
- GetSearchResultName
- GetSearchResultSize
To retrieve the next search result, pass the returned search handle to the FindNext method. When an application is finished with (or wants to abandon) a search operation, it must pass the associated search handle to the FindClose method in order to release the resources associated with it.
Since each search operation is identified by the search handle associated with it, applications may initiate additional search operations at any time, and may process each operation's search results in any manner it desires (sequentially, round-robin, etc.).
The value passed for Directory must be a vault-local absolute path.
The value passed for Query must be a search query constructed using the CBFS Storage Query Language; please refer to that topic for more information.
The Flags parameter controls search behavior. Among other things, it can be used to request that only specific pieces of information be returned, which can greatly improve performance. The value passed for this parameter should be constructed by OR'ing together zero or more of the following values:
CBFSSTORAGE_FF_NEED_NAME | 0x00000001 | Include entry names (without paths) when returning search results. |
CBFSSTORAGE_FF_NEED_FULL_NAME | 0x00000002 | Include fully-qualified entry names when returning search results. |
CBFSSTORAGE_FF_NEED_ATTRIBUTES | 0x00000004 | Include entry attributes when returning search results. |
CBFSSTORAGE_FF_NEED_SIZE | 0x00000008 | Include entry sizes when returning search results. |
CBFSSTORAGE_FF_NEED_METADATA_SIZE | 0x00000010 | Include entry metadata sizes when returning search results. |
CBFSSTORAGE_FF_NEED_TIMES | 0x00000020 | Include entry times when returning search results. |
CBFSSTORAGE_FF_NEED_LINK_DEST | 0x00000040 | Include symbolic link destinations when returning search results. |
CBFSSTORAGE_FF_EMULATE_FAT | 0x00001000 | Inserts . and .. pseudo-entries into search results for all directories except the root one. |
CBFSSTORAGE_FF_RECURSIVE | 0x00002000 | Search recursively in all subdirectories. |
CBFSSTORAGE_FF_CASE_INSENSITIVE | 0x00004000 | Forces case-insensitive search, even if the vault is case-sensitive. |
Note: This method can only be called when Active is true, and cannot be called within events.