Merge "zipsync handles symlink"
diff --git a/cmd/zipsync/zipsync.go b/cmd/zipsync/zipsync.go
index 294e5ef..aecdc3d 100644
--- a/cmd/zipsync/zipsync.go
+++ b/cmd/zipsync/zipsync.go
@@ -53,6 +53,16 @@
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() {
flag.Usage = func() {
fmt.Fprintln(os.Stderr, "usage: zipsync -d <output dir> [-l <output file>] [-f <pattern>] [zip]...")
@@ -122,7 +132,11 @@
if err != nil {
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()
files = append(files, filename)
}