fileutil

package module
v0.0.0-...-ce47dcc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 17, 2022 License: GPL-3.0 Imports: 19 Imported by: 3

README

fileutil

The package contains various helpers to interact with files

fileutil is made with 🖤 by the projectdiscovery team.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TimeoutError = errors.New("Timeout")

Functions

func CopyFile

func CopyFile(src, dst string) error

CopyFile from source to destination

func CreateFolder

func CreateFolder(path string) error

CreateFolder path

func CreateFolders

func CreateFolders(paths ...string) error

CreateFolders in the list

func DeleteFilesOlderThan

func DeleteFilesOlderThan(folder string, filter FileFilters) error

func DownloadFile

func DownloadFile(filepath string, url string) error

DownloadFile to specified path

func ExecutableName

func ExecutableName() string

func FileExists

func FileExists(filename string) bool

FileExists checks if the file exists in the provided path

func FolderExists

func FolderExists(foldername string) bool

FolderExists checks if the folder exists

func GetTempFileName

func GetTempFileName() (string, error)

GetTempFileName generate a temporary file name

func HasPermission

func HasPermission(fileName string, permission int) (bool, error)

HasPermission checks if the file has the requested permission

func HasStdin

func HasStdin() bool

HasStdin determines if the user has piped input

func IsReadable

func IsReadable(fileName string) (bool, error)

IsReadable verify file readability

func IsWriteable

func IsWriteable(fileName string) (bool, error)

IsWriteable verify file writeability

func Marshal

func Marshal(encodeType EncodeType, data []byte, obj interface{}) error

func MarshalToWriter

func MarshalToWriter(encodeType EncodeType, r io.Writer, obj interface{}) error

func ReadFile

func ReadFile(filename string) (chan string, error)

ReadFile with filename

func ReadFileWithBufferSize

func ReadFileWithBufferSize(filename string, maxCapacity int) (chan string, error)

// ReadFile with filename and specific buffer size

func ReadFileWithReader

func ReadFileWithReader(r io.Reader) (chan string, error)

ReadFileWithReader and stream on a channel

func ReadFileWithReaderAndBufferSize

func ReadFileWithReaderAndBufferSize(r io.Reader, maxCapacity int) (chan string, error)

ReadFileWithReader with specific buffer size and stream on a channel

func RemoveAll

func RemoveAll(paths ...string) (errored map[string]error)

RemoveAll specified paths, returning those that caused error

func Unmarshal

func Unmarshal(encodeType EncodeType, data []byte, obj interface{}) error

func UnmarshalFromReader

func UnmarshalFromReader(encodeType EncodeType, r io.Reader, obj interface{}) error

func UseMusl

func UseMusl(path string) (bool, error)

UseMusl checks if the specified elf file uses musl

Types

type EncodeType

type EncodeType uint8
const (
	YAML EncodeType = iota
	JSON
)

type FileFilters

type FileFilters struct {
	OlderThan    time.Duration
	Prefix       string
	Suffix       string
	RegexPattern string
	CustomCheck  func(filename string) bool
	Callback     func(filename string) error
}

type FrozenReader

type FrozenReader struct{}

FrozenReader is a reader that never returns

func (FrozenReader) Read

func (reader FrozenReader) Read(p []byte) (n int, err error)

Read into the buffer

type TimeoutReader

type TimeoutReader struct {
	Timeout time.Duration
	Reader  io.Reader
	// contains filtered or unexported fields
}

TimeoutReader is a reader wrapper that stops waiting after Timeout

func (TimeoutReader) Read

func (reader TimeoutReader) Read(p []byte) (n int, err error)

Read into the buffer

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL