fileutils

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2023 License: MIT Imports: 11 Imported by: 2

README

fileutils Build Status Go Report Card Coverage Status

Package fileutils provides useful, high-level file operations.

Details

  • IsFile & IsDir checks if file/directory exits
  • CopyFile copies a file from source to destination
  • CopyDir copies all files recursively from the source to destination directory
  • ListFiles returns sorted slice of file paths in directory
  • TempFileName returns a new temporary file name
  • SanitizePath cleans file path

Install and update

go get -u github.com/go-pkgz/fileutils

Documentation

Overview

Package fileutils provides useful, high-level file operations

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyDir

func CopyDir(src string, dst string) error

CopyDir copies all files from src to dst, recursively

func CopyFile

func CopyFile(src string, dst string) error

CopyFile copies a file from source to dest. Any existing file will be overwritten and attributes will not be copied

func IsDir

func IsDir(dirname string) bool

IsDir returns true if directory exists

func IsFile

func IsFile(filename string) bool

IsFile returns true if filename exists

func ListFiles

func ListFiles(directory string) (list []string, err error)

ListFiles gets recursive list of all files in a directory

func SanitizePath added in v0.2.0

func SanitizePath(s string) string

SanitizePath removes invalid characters from path

func TempFileName added in v0.2.0

func TempFileName(dir, pattern string) (string, error)

TempFileName returns a new temporary file name in the directory dir. The filename is generated by taking pattern and adding a random string to the end. If pattern includes a "*", the random string replaces the last "*". If dir is the empty string, TempFileName uses the default directory for temporary files (see os.TempDir). Multiple programs calling TempFileName simultaneously will not choose the same file name. some code borrowed from stdlib https://golang.org/src/io/ioutil/tempfile.go

Types

This section is empty.

Jump to

Keyboard shortcuts

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