Esempio n. 1
0
File: pathio.go Progetto: fxnn/gone
// guessExtension tries to append the file extension, if missing.
// If the given path points to a valid file, simply returns the argument.
// Otherwise, it looks for all files in the directory beginning with the
// filename and a dot ("."), and returns the first match in alphabetic order.
func (i *pathIO) guessExtension(p gopath.GoPath) gopath.GoPath {
	var match = p.Append(".*").GlobAny().PrependErr("couldn't guess extension")
	if match.Path() != "" {
		return i.syncedErrs(match)
	}
	return p
}