MCPcopy Create free account
hub / github.com/gokcehan/lf / getFileExtension

Function getFileExtension

misc.go:416–425  ·  view source on GitHub ↗

getFileExtension returns the extension of a file with a leading dot. It returns an empty string if extension could not be determined i.e. directories, filenames without extensions

(file fs.FileInfo)

Source from the content-addressed store, hash-verified

414// It returns an empty string if extension could not be determined
415// i.e. directories, filenames without extensions
416func getFileExtension(file fs.FileInfo) string {
417 if file.IsDir() {
418 return ""
419 }
420 if strings.Count(file.Name(), ".") == 1 && file.Name()[0] == '.' {
421 // hidden file without extension
422 return ""
423 }
424 return filepath.Ext(file.Name())
425}
426
427// truncateFilename truncates a filename at a given position.
428// The position is specified as percentage indicating where the truncation

Callers 6

TestGetFileExtensionFunction · 0.85
copyAllFunction · 0.85
newFileFunction · 0.85
moveAsyncMethod · 0.85
evalMethod · 0.85
truncateFilenameFunction · 0.85

Calls 2

IsDirMethod · 0.45
NameMethod · 0.45

Tested by 1

TestGetFileExtensionFunction · 0.68