File: archiver_unix.go

package info (click to toggle)
golang-github-saracen-fastzip 0.1.11-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 176 kB
  • sloc: makefile: 2
file content (32 lines) | stat: -rw-r--r-- 780 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//go:build !windows
// +build !windows

package fastzip

import (
	"io"
	"math/big"
	"os"
	"syscall"

	"github.com/klauspost/compress/zip"
	"github.com/saracen/zipextra"
)

func (a *Archiver) createHeader(fi os.FileInfo, hdr *zip.FileHeader) (io.Writer, error) {
	stat, ok := fi.Sys().(*syscall.Stat_t)
	if ok {
		hdr.Extra = append(hdr.Extra, zipextra.NewInfoZIPNewUnix(big.NewInt(int64(stat.Uid)), big.NewInt(int64(stat.Gid))).Encode()...)
	}

	return a.zw.CreateHeader(hdr)
}

func (a *Archiver) createRaw(fi os.FileInfo, hdr *zip.FileHeader) (io.Writer, error) {
	stat, ok := fi.Sys().(*syscall.Stat_t)
	if ok {
		hdr.Extra = append(hdr.Extra, zipextra.NewInfoZIPNewUnix(big.NewInt(int64(stat.Uid)), big.NewInt(int64(stat.Gid))).Encode()...)
	}

	return a.zw.CreateRaw(hdr)
}