Add support for hard links
This commit is contained in:
@@ -122,7 +122,12 @@ func (instruction *LinkInstruction) RunAsync(status chan (error)) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err := os.Symlink(instruction.Source, instruction.Target)
|
var err error
|
||||||
|
if *hard {
|
||||||
|
err = os.Link(instruction.Source, instruction.Target)
|
||||||
|
} else {
|
||||||
|
err = os.Symlink(instruction.Source, instruction.Target)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
status <- fmt.Errorf("failed creating symlink between %s%s%s and %s%s%s with error %s%+v%s", SourceColor, instruction.Source, DefaultColor, TargetColor, instruction.Target, DefaultColor, ErrorColor, err, DefaultColor)
|
status <- fmt.Errorf("failed creating symlink between %s%s%s and %s%s%s with error %s%+v%s", SourceColor, instruction.Source, DefaultColor, TargetColor, instruction.Target, DefaultColor, ErrorColor, err, DefaultColor)
|
||||||
return
|
return
|
||||||
|
3
main.go
3
main.go
@@ -32,10 +32,13 @@ var DirRegex, _ = regexp.Compile(`^(.+?)[/\\]sync$`)
|
|||||||
var FileRegex, _ = regexp.Compile(`^sync$`)
|
var FileRegex, _ = regexp.Compile(`^sync$`)
|
||||||
var programName = os.Args[0]
|
var programName = os.Args[0]
|
||||||
|
|
||||||
|
var hard *bool
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
recurse := flag.String("r", "", "recurse into directories")
|
recurse := flag.String("r", "", "recurse into directories")
|
||||||
file := flag.String("f", "", "file to read instructions from")
|
file := flag.String("f", "", "file to read instructions from")
|
||||||
debug := flag.Bool("d", false, "debug")
|
debug := flag.Bool("d", false, "debug")
|
||||||
|
hard = flag.Bool("h", false, "create hard links instead")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
if *debug {
|
if *debug {
|
||||||
|
Reference in New Issue
Block a user