github.com/cloudbase/juju-core@v0.0.0-20140504232958-a7271ac7912f/worker/uniter/tools_windows.go (about)

     1  // Copyright 2012, 2013 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package uniter
     5  
     6  import (
     7      "os"
     8      "path/filepath"
     9  
    10      "launchpad.net/juju-core/worker/uniter/jujuc"
    11      "launchpad.net/juju-core/utils"
    12  )
    13  
    14  // EnsureJujucSymlinks creates a symbolic link to jujuc within dir for each
    15  // hook command. If the commands already exist, this operation does nothing.
    16  
    17  func EnsureJujucSymlinks(dir string) (err error) {
    18      for _, name := range jujuc.CommandNames() {
    19          file := filepath.Join(dir, name)
    20          if _, err := os.Stat(file); err == nil {
    21              continue
    22          }
    23          jujudExe := filepath.Join(dir, "jujud.exe")
    24          err := utils.Symlink(jujudExe, filepath.FromSlash(file))
    25          if err == nil {
    26              continue
    27          }
    28          return err
    29      }
    30      return nil
    31  }