diff --git a/platform/other.go b/platform/other.go index bc2ddc1..d74e511 100644 --- a/platform/other.go +++ b/platform/other.go @@ -6,11 +6,6 @@ import( "path" ) -func SanitiseFilename(filename string) (newName string, e error) { - newName = filename - return -} - func DirOf(filename string) (dirname string, e error) { dirname = path.Dir(filename) return diff --git a/platform/windows.go b/platform/windows.go index c9dc5d1..68a5b48 100644 --- a/platform/windows.go +++ b/platform/windows.go @@ -6,16 +6,6 @@ import( "regexp" ) -func SanitiseFilename(filename string) (newName string, e error) { - r, e := regexp.Compile("[\\?<>:/\"\\\\|\\*]") - if e != nil { - return - } - - newName = r.ReplaceAllString(filename, "") - return -} - func DirOf(filename string) (dirname string, e error) { r, e := regexp.Compile(`\\[^\\]+$`) if e != nil { diff --git a/wimp-get.go b/wimp-get.go index 1c1c2e1..c479571 100644 --- a/wimp-get.go +++ b/wimp-get.go @@ -15,6 +15,16 @@ import ( "strings" ) +func SanitiseFilename(filename string) (newName string, e error) { + r, e := regexp.Compile("[\\?<>:/\"\\\\|\\*]") + if e != nil { + return + } + + newName = r.ReplaceAllString(filename, "") + return +} + func main() { if len(os.Args) != 2 { fmt.Printf("Usage: %s \n", os.Args[0]) @@ -68,7 +78,7 @@ func main() { } dirName := album.Artist+" - "+album.Title+" ("+fmt.Sprintf("%d", album.Year)+") [WEB FLAC]" - dirName, e = platform.SanitiseFilename(dirName) + dirName, e = SanitiseFilename(dirName) if e != nil { panic(e) } @@ -90,7 +100,7 @@ func main() { fmt.Printf("[%d/%s] %s...", track.Volume, num, track.Title) var filename = fmt.Sprintf("%s - %s.flac", num, track.Title) - filename, e = platform.SanitiseFilename(filename) + filename, e = SanitiseFilename(filename) if e != nil { panic(e) }