MCPcopy Create free account
hub / github.com/catboost/catboost / GetWinFileType

Function GetWinFileType

util/system/fstat.cpp:20–43  ·  view source on GitHub ↗

See https://docs.microsoft.com/en-us/windows/win32/fileio/file-attribute-constants for possible flag values

Source from the content-addressed store, hash-verified

18// See https://docs.microsoft.com/en-us/windows/win32/fileio/file-attribute-constants
19// for possible flag values
20static ui32 GetWinFileType(DWORD fileAttributes, ULONG reparseTag) {
21 // I'm not really sure, why it is done like this. MSDN tells that
22 // FILE_ATTRIBUTE_DEVICE is reserved for system use. Some more info is
23 // available at https://stackoverflow.com/questions/3419527/setting-file-attribute-device-in-visual-studio
24 // We should probably replace this with GetFileType call and check for
25 // FILE_TYPE_CHAR and FILE_TYPE_PIPE return values.
26 if (fileAttributes & FILE_ATTRIBUTE_DEVICE) {
27 return _S_IFCHR;
28 }
29
30 if (fileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) {
31 // We consider IO_REPARSE_TAG_SYMLINK and IO_REPARSE_TAG_MOUNT_POINT
32 // both to be symlinks to align with current WinReadLink behaviour.
33 if (reparseTag == IO_REPARSE_TAG_SYMLINK || reparseTag == IO_REPARSE_TAG_MOUNT_POINT) {
34 return _S_IFLNK;
35 }
36 }
37
38 if (fileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
39 return _S_IFDIR;
40 }
41
42 return _S_IFREG;
43}
44
45static ui32 GetFileMode(DWORD fileAttributes, ULONG reparseTag) {
46 ui32 mode = 0;

Callers 1

GetFileModeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected