Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

failsafe for empty names

Cette révision appartient à :
kilo 2017-11-08 12:06:57 +01:00 révisé par GitHub
Parent 9ffb5f1cde
révision cb8604d11a
Aucune clé n'a été trouvée pour cette signature dans la base de données
ID de la clé GPG: 4AEE18F83AFDEB23

Voir le fichier

@ -52,12 +52,18 @@ func (f *File) SetPath(path []string) error {
// Filename : Returns the filename of the file
func (f *File) Filename() string {
path := f.Path()
if len(path) == 0 {
return ""
}
return path[len(path)-1]
}
// FilenameWithoutExtension : Returns the filename of the file without the extension
func (f *File) FilenameWithoutExtension() string {
path := f.Path()
if len(path) == 0 {
return ""
}
fileName := path[len(path)-1]
index := strings.LastIndex(fileName, ".")
@ -71,6 +77,9 @@ func (f *File) FilenameWithoutExtension() string {
// FilenameExtension : Returns the extension of a filename, or an empty string
func (f *File) FilenameExtension() string {
path := f.Path()
if len(path) == 0 {
return ""
}
fileName := path[len(path)-1]
index := strings.LastIndex(fileName, ".")