Skip to content

Commit

Permalink
mingw: move the file_attr_to_st_mode() function definition
Browse files Browse the repository at this point in the history
In preparation for making this function a bit more complicated (to allow
for special-casing the `ContainerMappedDirectories` in Windows
containers, which look like a symbolic link, but are not), let's move it
out of the header.

Signed-off-by: JiSeop Moon <zcube@zcube.kr>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  • Loading branch information
ZCube authored and dscho committed Sep 16, 2022
1 parent 6b57168 commit c32a4e7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
14 changes: 14 additions & 0 deletions compat/mingw.c
Expand Up @@ -3906,3 +3906,17 @@ int is_inside_windows_container(void)

return inside_container;
}

int file_attr_to_st_mode (DWORD attr, DWORD tag)
{
int fMode = S_IREAD;
if ((attr & FILE_ATTRIBUTE_REPARSE_POINT) && tag == IO_REPARSE_TAG_SYMLINK)
fMode |= S_IFLNK;
else if (attr & FILE_ATTRIBUTE_DIRECTORY)
fMode |= S_IFDIR;
else
fMode |= S_IFREG;
if (!(attr & FILE_ATTRIBUTE_READONLY))
fMode |= S_IWRITE;
return fMode;
}
14 changes: 1 addition & 13 deletions compat/win32.h
Expand Up @@ -6,19 +6,7 @@
#include <windows.h>
#endif

static inline int file_attr_to_st_mode (DWORD attr, DWORD tag)
{
int fMode = S_IREAD;
if ((attr & FILE_ATTRIBUTE_REPARSE_POINT) && tag == IO_REPARSE_TAG_SYMLINK)
fMode |= S_IFLNK;
else if (attr & FILE_ATTRIBUTE_DIRECTORY)
fMode |= S_IFDIR;
else
fMode |= S_IFREG;
if (!(attr & FILE_ATTRIBUTE_READONLY))
fMode |= S_IWRITE;
return fMode;
}
extern int file_attr_to_st_mode (DWORD attr, DWORD tag);

static inline int get_file_attr(const char *fname, WIN32_FILE_ATTRIBUTE_DATA *fdata)
{
Expand Down

0 comments on commit c32a4e7

Please sign in to comment.