Added the Stat API

This commit is contained in:
Diptanu Choudhury
2016-01-12 15:25:51 -08:00
parent 744c226c23
commit cbcdaec3fe
4 changed files with 43 additions and 1 deletions

View File

@@ -41,6 +41,7 @@ type AllocDir struct {
type AllocFile struct {
Name string
IsDir bool
Size int64
}
func NewAllocDir(allocDir string) *AllocDir {
@@ -233,11 +234,26 @@ func (d *AllocDir) FSList(path string) ([]*AllocFile, error) {
files[idx] = &AllocFile{
Name: info.Name(),
IsDir: info.IsDir(),
Size: info.Size(),
}
}
return files, err
}
func (d *AllocDir) FSStat(path string) (*AllocFile, error) {
info, err := os.Stat(path)
if err != nil {
return nil, err
}
return &AllocFile{
Size: info.Size(),
Name: info.Name(),
IsDir: info.IsDir(),
}, nil
}
func fileCopy(src, dst string, perm os.FileMode) error {
// Do a simple copy.
srcFile, err := os.Open(src)