(path string, dirEnt fs.DirEntry)
| 153 | } |
| 154 | |
| 155 | func DetectMimeTypeWithDirEnt(path string, dirEnt fs.DirEntry) string { |
| 156 | if dirEnt != nil { |
| 157 | if dirEnt.IsDir() { |
| 158 | return "directory" |
| 159 | } |
| 160 | mode := dirEnt.Type() |
| 161 | if mode&os.ModeNamedPipe == os.ModeNamedPipe { |
| 162 | return "pipe" |
| 163 | } |
| 164 | charDevice := os.ModeDevice | os.ModeCharDevice |
| 165 | if mode&charDevice == charDevice { |
| 166 | return "character-special" |
| 167 | } |
| 168 | if mode&os.ModeDevice == os.ModeDevice { |
| 169 | return "block-special" |
| 170 | } |
| 171 | } |
| 172 | ext := strings.ToLower(filepath.Ext(path)) |
| 173 | if mimeType, ok := StaticMimeTypeMap[ext]; ok { |
| 174 | return mimeType |
| 175 | } |
| 176 | return "" |
| 177 | } |
| 178 | |
| 179 | func AtomicWriteFile(fileName string, data []byte, perm os.FileMode) error { |
| 180 | tmpFileName := fileName + TempFileSuffix |
no test coverage detected