Merge "zipsync handles symlink"
This commit is contained in:
commit
83f738cae2
1 changed files with 15 additions and 1 deletions
|
@ -53,6 +53,16 @@ func writeFile(filename string, in io.Reader, perm os.FileMode) error {
|
||||||
return out.Close()
|
return out.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func writeSymlink(filename string, in io.Reader) error {
|
||||||
|
b, err := ioutil.ReadAll(in)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
dest := string(b)
|
||||||
|
err = os.Symlink(dest, filename)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
flag.Usage = func() {
|
flag.Usage = func() {
|
||||||
fmt.Fprintln(os.Stderr, "usage: zipsync -d <output dir> [-l <output file>] [-f <pattern>] [zip]...")
|
fmt.Fprintln(os.Stderr, "usage: zipsync -d <output dir> [-l <output file>] [-f <pattern>] [zip]...")
|
||||||
|
@ -122,7 +132,11 @@ func main() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
must(writeFile(filename, in, f.FileInfo().Mode()))
|
if f.FileInfo().Mode()&os.ModeSymlink != 0 {
|
||||||
|
must(writeSymlink(filename, in))
|
||||||
|
} else {
|
||||||
|
must(writeFile(filename, in, f.FileInfo().Mode()))
|
||||||
|
}
|
||||||
in.Close()
|
in.Close()
|
||||||
files = append(files, filename)
|
files = append(files, filename)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue