launchpad.net/~rogpeppe/juju-core/500-errgo-fix@v0.0.0-20140213181702-000000002356/agent/tools/diskmanager.go (about)

     1  // Copyright 2013 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package tools
     5  
     6  import (
     7  	"io"
     8  
     9  	"launchpad.net/juju-core/tools"
    10  	"launchpad.net/juju-core/version"
    11  )
    12  
    13  // DiskManager keeps track of a collections of Juju agent tools in a directory
    14  // structure on disk.
    15  type DiskManager struct {
    16  	dataDir string
    17  }
    18  
    19  // NewDiskManager returns a DiskManager handling a given directory.
    20  // *DiskManager conforms to the ToolsManager interface
    21  func NewDiskManager(dataDir string) *DiskManager {
    22  	return &DiskManager{dataDir: dataDir}
    23  }
    24  
    25  func (d *DiskManager) ReadTools(vers version.Binary) (*tools.Tools, error) {
    26  	return ReadTools(d.dataDir, vers)
    27  }
    28  
    29  func (d *DiskManager) UnpackTools(tools *tools.Tools, r io.Reader) error {
    30  	return UnpackTools(d.dataDir, tools, r)
    31  }
    32  
    33  func (d *DiskManager) SharedToolsDir(vers version.Binary) string {
    34  	return SharedToolsDir(d.dataDir, vers)
    35  }