~nskaggs/+junk/xenial-test

« back to all changes in this revision

Viewing changes to src/github.com/juju/utils/symlink/symlink_posix.go

  • Committer: Nicholas Skaggs
  • Date: 2016-10-24 20:56:05 UTC
  • Revision ID: nicholas.skaggs@canonical.com-20161024205605-z8lta0uvuhtxwzwl
Initi with beta15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright 2014 Canonical Ltd.
 
2
// Licensed under the LGPLv3, see LICENCE file for details.
 
3
 
 
4
// +build linux darwin
 
5
 
 
6
package symlink
 
7
 
 
8
import (
 
9
        "os"
 
10
 
 
11
        "github.com/juju/errors"
 
12
)
 
13
 
 
14
// New is a wrapper function for os.Symlink() on Linux
 
15
func New(oldname, newname string) error {
 
16
        return os.Symlink(oldname, newname)
 
17
}
 
18
 
 
19
// Read is a wrapper for os.Readlink() on Linux
 
20
func Read(link string) (string, error) {
 
21
        return os.Readlink(link)
 
22
}
 
23
 
 
24
func IsSymlink(path string) (bool, error) {
 
25
        st, err := os.Lstat(path)
 
26
        if err != nil {
 
27
                return false, errors.Trace(err)
 
28
        }
 
29
        return st.Mode()&os.ModeSymlink != 0, nil
 
30
}
 
31
 
 
32
// getLongPathAsString does nothing on linux. Its here for compatibillity
 
33
// with the windows implementation
 
34
func getLongPathAsString(path string) (string, error) {
 
35
        return path, nil
 
36
}