MCPcopy Index your code
hub / github.com/crowdsecurity/crowdsec / writeFileToZip

Method writeFileToZip

cmd/crowdsec-cli/clisupport/support.go:497–513  ·  view source on GitHub ↗

writeFileToZip adds a file to the zip archive, from a file, and retains the mtime

(zw *zip.Writer, filename string, fromFile string)

Source from the content-addressed store, hash-verified

495
496// writeFileToZip adds a file to the zip archive, from a file, and retains the mtime
497func (cli *cliSupport) writeFileToZip(zw *zip.Writer, filename string, fromFile string) {
498 mtime := time.Now()
499
500 fi, err := os.Stat(fromFile)
501 if err == nil {
502 mtime = fi.ModTime()
503 }
504
505 fin, err := os.Open(fromFile)
506 if err != nil {
507 log.Errorf("could not open file %s: %s", fromFile, err)
508 return
509 }
510 defer fin.Close()
511
512 cli.writeToZip(zw, filename, mtime, fin)
513}
514
515func (cli *cliSupport) dump(ctx context.Context, outFile string, fast bool) error {
516 var skipCAPI, skipLAPI, skipAgent bool

Callers 4

dumpProfilesMethod · 0.95
dumpAcquisitionConfigMethod · 0.95
dumpLogsMethod · 0.95
dumpCrashMethod · 0.95

Calls 3

writeToZipMethod · 0.95
OpenMethod · 0.80
CloseMethod · 0.45

Tested by

no test coverage detected