Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Library - Allow FindFilesWithPattern to return STATUS_NOT_IMPLEMENTED #1096

Merged
merged 1 commit into from
Jun 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions dokan/directory.c
Original file line number Diff line number Diff line change
Expand Up @@ -692,21 +692,28 @@ VOID DispatchDirectoryInformation(PDOKAN_IO_EVENT IoEvent) {
return;
}

if ((!searchPattern ||
!IoEvent->DokanInstance->DokanOperations->FindFilesWithPattern) &&
IoEvent->DokanInstance->DokanOperations->FindFiles) {
status = IoEvent->DokanInstance->DokanOperations->FindFiles(
IoEvent->EventContext->Operation.Directory.DirectoryName,
DokanFillFileData, &IoEvent->DokanFileInfo);
EndFindFilesCommon(IoEvent, status);
status = STATUS_NOT_IMPLEMENTED;

} else if (IoEvent->DokanInstance->DokanOperations->FindFilesWithPattern) {
// Reminder: FindFilesWithPattern may not be implemented by returning STATUS_NOT_IMPLEMENTED.
if (IoEvent->DokanInstance->DokanOperations->FindFilesWithPattern) {
KoltesDigital marked this conversation as resolved.
Show resolved Hide resolved
status = IoEvent->DokanInstance->DokanOperations->FindFilesWithPattern(
IoEvent->EventContext->Operation.Directory.DirectoryName,
searchPattern ? searchPattern : L"*", DokanFillFileData,
&IoEvent->DokanFileInfo);
}

// And if not, try with FindFiles.
if (status == STATUS_NOT_IMPLEMENTED &&
IoEvent->DokanInstance->DokanOperations->FindFiles) {
status = IoEvent->DokanInstance->DokanOperations->FindFiles(
IoEvent->EventContext->Operation.Directory.DirectoryName,
DokanFillFileData, &IoEvent->DokanFileInfo);
}

if (status != STATUS_NOT_IMPLEMENTED) {
EndFindFilesCommon(IoEvent, status);
} else {
// Neither FindFilesWithPattern nor FindFiles are implemented.
IoEvent->EventResult->Status = STATUS_NOT_IMPLEMENTED;
EventCompletion(IoEvent);
}
Expand Down
6 changes: 3 additions & 3 deletions dokan/dokan.h
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,8 @@ typedef struct _DOKAN_OPERATIONS {
* \brief FindFiles Dokan API callback
*
* List all files in the requested path.
* If this function is not implemented by not assigning the function pointer,
* \ref DOKAN_OPERATIONS.FindFilesWithPattern will instead be called with a wildcard as pattern.
* \ref DOKAN_OPERATIONS.FindFilesWithPattern is checked first. If it is not implemented or
* returns \c STATUS_NOT_IMPLEMENTED, then FindFiles is called, if assigned.
* It is recommended to have this implemented for performance reason.
*
* \param FileName File path requested by the Kernel on the FileSystem.
Expand All @@ -421,7 +421,7 @@ typedef struct _DOKAN_OPERATIONS {
* The search pattern is a Windows MS-DOS-style expression.
* It can contain wild cards and extended characters or none of them. See \ref DokanIsNameInExpression.
*
* If the function is not implemented by not assigning the function pointer, \ref DOKAN_OPERATIONS.FindFiles
* If the function is not implemented, \ref DOKAN_OPERATIONS.FindFiles
* will be called instead and the result will be filtered internally by the library.
* It is recommended to have this implemented for performance reason.
*
Expand Down