File: util_pipe.go

package info (click to toggle)
golang-github-johanneskaufmann-html-to-markdown 2.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,084 kB
  • sloc: makefile: 3
file content (25 lines) | stat: -rw-r--r-- 328 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
package cmd

import (
	"io"
	"io/fs"
	"os"
)

type ReadWriterWithStat interface {
	io.ReadWriter

	Stat() (fs.FileInfo, error)
}

func isPipe(f ReadWriterWithStat) (bool, error) {
	stat, err := f.Stat()
	if err != nil {
		return false, err
	}

	if stat.Mode()&os.ModeCharDevice == 0 {
		return true, nil
	}
	return false, nil
}