| 74 | ) |
| 75 | |
| 76 | func WinSymlinkDir(path string, bits os.FileMode) bool { |
| 77 | // Windows compatibility layer doesn't expose symlink target type through fileInfo |
| 78 | // so we need to check file attributes and extension patterns |
| 79 | isFileSymlink := func(filepath string) bool { |
| 80 | if len(filepath) == 0 { |
| 81 | return false |
| 82 | } |
| 83 | return strings.LastIndex(filepath, ".") > strings.LastIndex(filepath, "/") |
| 84 | } |
| 85 | |
| 86 | flags := uint32(bits >> 12) |
| 87 | |
| 88 | if flags == winFlagSoftlink { |
| 89 | return !isFileSymlink(path) |
| 90 | } else if flags == winFlagJunction { |
| 91 | return true |
| 92 | } else { |
| 93 | return false |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | // on error just returns "" |
| 98 | // does not return "application/octet-stream" as this is considered a detection failure |