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

Expose FindData struct #205

Open
hasufell opened this issue May 14, 2022 · 5 comments
Open

Expose FindData struct #205

hasufell opened this issue May 14, 2022 · 5 comments
Assignees

Comments

@hasufell
Copy link
Member

Expose FindData struct: https://docs.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-win32_find_dataa

typedef struct _WIN32_FIND_DATAW {
  DWORD    dwFileAttributes;
  FILETIME ftCreationTime;
  FILETIME ftLastAccessTime;
  FILETIME ftLastWriteTime;
  DWORD    nFileSizeHigh;
  DWORD    nFileSizeLow;
  DWORD    dwReserved0;
  DWORD    dwReserved1;
  WCHAR    cFileName[MAX_PATH];
  WCHAR    cAlternateFileName[14];
  DWORD    dwFileType; // Obsolete. Do not use.
  DWORD    dwCreatorType; // Obsolete. Do not use
  WORD     wFinderFlags; // Obsolete. Do not use
} WIN32_FIND_DATAW, *PWIN32_FIND_DATAW, *LPWIN32_FIND_DATAW;

Otherwise it's hard to determine file-type efficiently when using findFirstFile/findNextFile: https://hackage.haskell.org/package/Win32-2.13.2.0/docs/System-Win32-File.html#v:findFirstFile

@hasufell
Copy link
Member Author

ping @Mistuke

@Mistuke
Copy link
Contributor

Mistuke commented May 3, 2024

Ah I missed this, I'm on holiday atm and will do it when I'm back in two weeks.

@Mistuke Mistuke self-assigned this May 3, 2024
@hasufell
Copy link
Member Author

hasufell commented May 3, 2024

The comment in the struct for dwFileType seem to say:

Obsolete. Do not use

What else do we use without incurring another syscall?

@Mistuke
Copy link
Contributor

Mistuke commented May 15, 2024

The comment in the struct for dwFileType seem to say:

Obsolete. Do not use

Those entries never existed on Windows. This is a documentation bug, if you look in the windows sdk headers, they're guarded by _MAC. i.e. they only ever worked on MACOS from the early days of Microsoft and Apple.

It's just that MSDN seems to render them that way. the mingw-w64 headers for instance don't even contain them

https://github.com/Alexpux/mingw-w64/blob/master/mingw-w64-headers/include/minwinbase.h#L61

What else do we use without incurring another syscall?

It's not entirely clear to me what dwFileType actually contained.. Is what you're after in https://learn.microsoft.com/en-us/windows/win32/fileio/file-attribute-constants? i.e. dwFileAttributes.

@hasufell
Copy link
Member Author

If dwFileAttributes allows us to determine the file type, then that will be enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants