go-judge/file/localfile/localfile.go
2019-09-01 20:40:34 -07:00

34 lines
499 B
Go

package localfile
import (
"io/ioutil"
"os"
)
// File stores a path to represent a local file
type File struct {
path string
}
// New creats a wrapper to path
func New(path string) *File {
return &File{
path: path,
}
}
// Name get the path
func (f *File) Name() string {
return f.path
}
// Content reads file content
func (f *File) Content() ([]byte, error) {
return ioutil.ReadFile(f.path)
}
// Open opens the file
func (f *File) Open() (*os.File, error) {
return os.Open(f.path)
}