Skip to content

Commit

Permalink
Library - Allow FindFilesWithPattern to return STATUS_NOT_IMPLEMENTED
Browse files Browse the repository at this point in the history
Reverts 9eb4d15
  • Loading branch information
KoltesDigital committed Jun 2, 2022
1 parent c0a59a4 commit 7aed978
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
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) {
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

0 comments on commit 7aed978

Please sign in to comment.