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 1, 2022
1 parent c0a59a4 commit 9d1a74f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
28 changes: 19 additions & 9 deletions dokan/directory.c
Original file line number Diff line number Diff line change
Expand Up @@ -692,20 +692,30 @@ 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);

} else if (IoEvent->DokanInstance->DokanOperations->FindFilesWithPattern) {
if (IoEvent->DokanInstance->DokanOperations->FindFilesWithPattern) {
status = IoEvent->DokanInstance->DokanOperations->FindFilesWithPattern(
IoEvent->EventContext->Operation.Directory.DirectoryName,
searchPattern ? searchPattern : L"*", DokanFillFileData,
&IoEvent->DokanFileInfo);

// FindFilesWithPattern is not implemented because it returned STATUS_NOT_IMPLEMENTED.
if (status == STATUS_NOT_IMPLEMENTED &&
IoEvent->DokanInstance->DokanOperations->FindFiles) {
status = IoEvent->DokanInstance->DokanOperations->FindFiles(
IoEvent->EventContext->Operation.Directory.DirectoryName,
DokanFillFileData, &IoEvent->DokanFileInfo);
}

EndFindFilesCommon(IoEvent, status);

// FindFilesWithPattern is not implemented because it is not defined.
} else if (IoEvent->DokanInstance->DokanOperations->FindFiles) {
status = IoEvent->DokanInstance->DokanOperations->FindFiles(
IoEvent->EventContext->Operation.Directory.DirectoryName,
DokanFillFileData, &IoEvent->DokanFileInfo);
EndFindFilesCommon(IoEvent, status);

// Neither FindFilesWithPattern nor FindFiles are implemented.
} else {
IoEvent->EventResult->Status = STATUS_NOT_IMPLEMENTED;
EventCompletion(IoEvent);
Expand Down
8 changes: 4 additions & 4 deletions dokan/dokan.h
Original file line number Diff line number Diff line change
Expand Up @@ -399,10 +399,10 @@ 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.
* It is recommended to have this implemented for performance reason.
* List all files in the requested path
* \ref DOKAN_OPERATIONS.FindFilesWithPattern is checked first. If it is not implemented or
* returns \c STATUS_NOT_IMPLEMENTED, then FindFiles is called, if implemented.
*
* \param FileName File path requested by the Kernel on the FileSystem.
* \param FillFindData Callback that has to be called with PWIN32_FIND_DATAW that contain file information.
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 9d1a74f

Please sign in to comment.