Renamed AllocFile to AllocFileInfo

This commit is contained in:
Diptanu Choudhury
2016-01-13 17:18:10 -08:00
parent 78d03616f6
commit 4345fc9bee
3 changed files with 15 additions and 15 deletions

View File

@@ -426,14 +426,14 @@ func (r *AllocRunner) WaitCh() <-chan struct{} {
return r.waitCh
}
func (r *AllocRunner) FSList(path string) ([]*allocdir.AllocFile, error) {
return r.ctx.AllocDir.FSList(path)
func (r *AllocRunner) FSList(path string) ([]*allocdir.AllocFileInfo, error) {
return r.ctx.AllocDir.List(path)
}
func (r *AllocRunner) FSStat(path string) (*allocdir.AllocFile, error) {
return r.ctx.AllocDir.FSStat(path)
func (r *AllocRunner) FSStat(path string) (*allocdir.AllocFileInfo, error) {
return r.ctx.AllocDir.Stat(path)
}
func (r *AllocRunner) FSReadAt(allocID string, path string, offset int64, limit int64, w io.Writer) error {
return r.ctx.AllocDir.FSReadAt(allocID, path, offset, limit, w)
return r.ctx.AllocDir.ReadAt(allocID, path, offset, limit, w)
}

View File

@@ -38,7 +38,7 @@ type AllocDir struct {
mounted []string
}
type AllocFile struct {
type AllocFileInfo struct {
Name string
IsDir bool
Size int64
@@ -223,15 +223,15 @@ func (d *AllocDir) MountSharedDir(task string) error {
return nil
}
func (d *AllocDir) FSList(path string) ([]*AllocFile, error) {
func (d *AllocDir) List(path string) ([]*AllocFileInfo, error) {
p := filepath.Join(d.AllocDir, path)
finfos, err := ioutil.ReadDir(p)
if err != nil {
return []*AllocFile{}, nil
return []*AllocFileInfo{}, nil
}
files := make([]*AllocFile, len(finfos))
files := make([]*AllocFileInfo, len(finfos))
for idx, info := range finfos {
files[idx] = &AllocFile{
files[idx] = &AllocFileInfo{
Name: info.Name(),
IsDir: info.IsDir(),
Size: info.Size(),
@@ -240,21 +240,21 @@ func (d *AllocDir) FSList(path string) ([]*AllocFile, error) {
return files, err
}
func (d *AllocDir) FSStat(path string) (*AllocFile, error) {
func (d *AllocDir) Stat(path string) (*AllocFileInfo, error) {
p := filepath.Join(d.AllocDir, path)
info, err := os.Stat(p)
if err != nil {
return nil, err
}
return &AllocFile{
return &AllocFileInfo{
Size: info.Size(),
Name: info.Name(),
IsDir: info.IsDir(),
}, nil
}
func (d *AllocDir) FSReadAt(allocID string, path string, offset int64, limit int64, w io.Writer) error {
func (d *AllocDir) ReadAt(allocID string, path string, offset int64, limit int64, w io.Writer) error {
p := filepath.Join(d.AllocDir, path)
f, err := os.Open(p)
if err != nil {

View File

@@ -355,7 +355,7 @@ func (c *Client) Node() *structs.Node {
return c.config.Node
}
func (c *Client) FSList(allocID string, path string) ([]*allocdir.AllocFile, error) {
func (c *Client) FSList(allocID string, path string) ([]*allocdir.AllocFileInfo, error) {
ar, ok := c.allocs[allocID]
if !ok {
return nil, fmt.Errorf("alloc not present")
@@ -364,7 +364,7 @@ func (c *Client) FSList(allocID string, path string) ([]*allocdir.AllocFile, err
return ar.FSList(path)
}
func (c *Client) FSStat(allocID string, path string) (*allocdir.AllocFile, error) {
func (c *Client) FSStat(allocID string, path string) (*allocdir.AllocFileInfo, error) {
ar, ok := c.allocs[allocID]
if !ok {
return nil, fmt.Errorf("alloc not found")