MCPcopy
hub / github.com/wavetermdev/waveterm / statToFileInfo

Function statToFileInfo

pkg/wshrpc/wshremote/wshremote_file.go:281–299  ·  view source on GitHub ↗
(fullPath string, finfo fs.FileInfo, extended bool)

Source from the content-addressed store, hash-verified

279}
280
281func statToFileInfo(fullPath string, finfo fs.FileInfo, extended bool) *wshrpc.FileInfo {
282 mimeType := fileutil.DetectMimeType(fullPath, finfo, extended)
283 rtn := &wshrpc.FileInfo{
284 Path: wavebase.ReplaceHomeDir(fullPath),
285 Dir: computeDirPart(fullPath),
286 Name: finfo.Name(),
287 Size: finfo.Size(),
288 Mode: finfo.Mode(),
289 ModeStr: finfo.Mode().String(),
290 ModTime: finfo.ModTime().UnixMilli(),
291 IsDir: finfo.IsDir(),
292 MimeType: mimeType,
293 SupportsMkdir: true,
294 }
295 if finfo.IsDir() {
296 rtn.Size = -1
297 }
298 return rtn
299}
300
301// fileInfo might be null
302func checkIsReadOnly(path string, fileInfo fs.FileInfo, exists bool) bool {

Callers 3

fileInfoInternalMethod · 0.85

Calls 9

DetectMimeTypeFunction · 0.92
ReplaceHomeDirFunction · 0.92
computeDirPartFunction · 0.85
ModeMethod · 0.80
ModTimeMethod · 0.80
NameMethod · 0.45
SizeMethod · 0.45
StringMethod · 0.45
IsDirMethod · 0.45

Tested by

no test coverage detected