func FilterTo(dst, src string, trunc bool, filter io2.LineFilterFunc) error {
	return Read(src, func(sfd *os.File) (err error) {
		return OpenOrCreate(dst, trunc, func(dfd *os.File) error {
			return io2.Filter(sfd, dfd, true, filter)
		})
	})
}
FilterTo filter file content with given filter, then write result
to dest file
package file
import (
	"io"
	"io/ioutil"
	"os"
	"path/filepath"
	"github.com/cosiner/gohper/errors"
	"github.com/cosiner/gohper/io2"
)
const ErrDestIsFile = errors.Err("destination is a file")
type FileOpFunc func(*os.File) error
func Open(fname string, flags int, fn FileOpFunc) error {
	fd, err := os.OpenFile(fname, flags, FilePerm)
	if err != nil {
		return err
	}
	if fn != nil {
		err = fn(fd)
	}
	if e := fd.Close(); e != nil && err == nil {
		err = e
	}
	return io2.NonEOF(err)
}
func WriteFlag(trunc bool) int {
	if trunc {
		return os.O_TRUNC
	}
	return os.O_APPEND
}
func FirstLine(src string) (line string, err error) {
	err = Filter(src, func(_ int, l []byte) (error) {
		line = string(l)
		return io.EOF
	})
	return
}
func Filter(src string, filter func(int, []byte) error) error {
	return Read(src, func(fd *os.File) (err error) {
		return io2.FilterRead(fd, filter)
	})
}