MCPcopy Index your code
hub / github.com/wavetermdev/waveterm / DetectMimeTypeWithDirEnt

Function DetectMimeTypeWithDirEnt

pkg/util/fileutil/fileutil.go:155–177  ·  view source on GitHub ↗
(path string, dirEnt fs.DirEntry)

Source from the content-addressed store, hash-verified

153}
154
155func 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
179func AtomicWriteFile(fileName string, data []byte, perm os.FileMode) error {
180 tmpFileName := fileName + TempFileSuffix

Callers 1

fetchFileSuggestionsFunction · 0.92

Calls 2

TypeMethod · 0.80
IsDirMethod · 0.45

Tested by

no test coverage detected