pathinfo

pathinfo

[code=golang]
import (
    "path/filepath"
)

func pathinfo(path string) map[string]string {
    result := make(map[string]string)

    filename := filepath.Base(path)
    ext := filepath.Ext(filename)

    dirname, basename := filepath.Split(path)
    basename = basename[:len(basename)-len(ext)]

    result["dirname"] = dirname
    result["basename"] = basename
    result["extension"] = ext
    result["filename"] = filename

    return result
}
[/code]