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)
| 414 | // It returns an empty string if extension could not be determined |
| 415 | // i.e. directories, filenames without extensions |
| 416 | func 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 |