dokan-dev / dokany

User mode file system library for windows with FUSE Wrapper
http://dokan-dev.github.io
5.23k stars 666 forks source link

GetFileInformation Not Called by FileDateTime in VB6 #1220

Closed smaramwbc closed 4 months ago

smaramwbc commented 4 months ago

When using the FileDateTime function in VB.NET to get the creation time of a file located on a Dokan drive, the DOKAN_OPERATIONS.GetFileInformation() callback is correctly invoked. This behavior is as expected and ensures that file information is accurately retrieved from the Dokan drive.

However, when the FileDateTime function is used in VB6 to retrieve the creation time of a file on the same Dokan drive, the DOKAN_OPERATIONS.GetFileInformation() callback is not called. This discrepancy between VB.NET and VB6 is problematic because it prevents consistent behavior across different versions of Visual Basic.

For reference, here is the documentation for the FileDateTime function: FileDateTime Function (Microsoft Docs).

Expected Behavior: When FileDateTime(dokan_drive\to\path) is called in VB6, it should trigger the DOKAN_OPERATIONS.GetFileInformation() callback, just as it does in VB.NET. This would ensure consistent file information retrieval from Dokan drives across different versions of Visual Basic.

Steps to Reproduce: Set up a Dokan drive and ensure it is mounted. Create a file on the Dokan drive. Use VB.NET to call FileDateTime(dokan_drive\to\path) and observe that DOKAN_OPERATIONS.GetFileInformation() is called. Use VB6 to call FileDateTime(dokan_drive\to\path) and observe that DOKAN_OPERATIONS.GetFileInformation() is not called.

VB.NET Example:

Dim creationTime As DateTime = FileDateTime("dokan_drive\to\path")
' DOKAN_OPERATIONS.GetFileInformation() is called

VB6 Example:

Dim creationTime As Date
creationTime = FileDateTime("dokan_drive\to\path")
' DOKAN_OPERATIONS.GetFileInformation() is NOT called

Environment: Dokan Version: 2.1.0 Operating System: Win10 & Win11

Thank you for your attention to this matter. If you could provide any advice on how to fix this issue, I would be pleased to contribute to the solution.

LTRData commented 4 months ago

This behaviour is expected. Some applications do not open a handle and query information to get file timestamps using that handle, instead they rely on directory information about the file. Therefore, there is no guarantee that GetFileInformation will be called in this scenario, you need to return the file information for a file in FindFiles and/or FindFilesWithPattern too.

smaramwbc commented 4 months ago

I successfully implemented this and it works perfectly. Thank you, @LTRData

Now, I'm addressing a new issue with case insensitivity and VB6, but I will seek further help if I am not able to solve it on my own.