From 9d1a74f6caceaf59b0de6146e6f38b923c01827d Mon Sep 17 00:00:00 2001 From: Jonathan Giroux Date: Wed, 1 Jun 2022 16:26:29 +0200 Subject: [PATCH] Library - Allow FindFilesWithPattern to return STATUS_NOT_IMPLEMENTED Reverts 9eb4d15bc4c533b73dd718b3114c0be758f874d9 --- dokan/directory.c | 28 +++++++++++++++++++--------- dokan/dokan.h | 8 ++++---- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/dokan/directory.c b/dokan/directory.c index 784b7b4e..3e796f70 100644 --- a/dokan/directory.c +++ b/dokan/directory.c @@ -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); diff --git a/dokan/dokan.h b/dokan/dokan.h index 1696d792..17fbd877 100644 --- a/dokan/dokan.h +++ b/dokan/dokan.h @@ -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. @@ -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. *