win32 icon indicating copy to clipboard operation
win32 copied to clipboard

Expose `FindData` struct

Open hasufell opened this issue 3 years ago • 5 comments

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 avatar May 14 '22 22:05 hasufell

ping @Mistuke

hasufell avatar Apr 29 '24 16:04 hasufell

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

Mistuke avatar May 03 '24 03:05 Mistuke

The comment in the struct for dwFileType seem to say:

Obsolete. Do not use

What else do we use without incurring another syscall?

hasufell avatar May 03 '24 04:05 hasufell

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.

Mistuke avatar May 15 '24 18:05 Mistuke

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

hasufell avatar May 16 '24 02:05 hasufell