lib/symlinks need not depend on protocol

This commit is contained in:
Jakob Borg
2015-09-04 12:54:01 +02:00
parent 21c3994650
commit 446a938b06
6 changed files with 109 additions and 40 deletions

View File

@@ -11,7 +11,6 @@ package symlinks
import (
"os"
"github.com/syncthing/protocol"
"github.com/syncthing/syncthing/lib/osutil"
)
@@ -19,23 +18,24 @@ var (
Supported = true
)
func Read(path string) (string, uint32, error) {
var mode uint32
stat, err := os.Stat(path)
if err != nil {
mode = protocol.FlagSymlinkMissingTarget
} else if stat.IsDir() {
mode = protocol.FlagDirectory
func Read(path string) (string, TargetType, error) {
tt := TargetUnknown
if stat, err := os.Stat(path); err == nil {
if stat.IsDir() {
tt = TargetDirectory
} else {
tt = TargetFile
}
}
path, err = os.Readlink(path)
path, err := os.Readlink(path)
return osutil.NormalizedFilename(path), mode, err
return osutil.NormalizedFilename(path), tt, err
}
func Create(source, target string, flags uint32) error {
func Create(source, target string, tt TargetType) error {
return os.Symlink(osutil.NativeFilename(target), source)
}
func ChangeType(path string, flags uint32) error {
func ChangeType(path string, tt TargetType) error {
return nil
}