file

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotDirectory = errors.New("not directory")

ErrNotDirectory is returned when the path is not a directory.

View Source
var ErrNotRegularFile = errors.New("not regular file")

ErrNotRegularFile is returned when the file is not an regular file.

Functions

func CopyDirToDir added in v1.1.0

func CopyDirToDir(src, dst string) error

CopyDirToDir copies contents in src dir to dst dir. Only regular files are copied. Existing files will be overwritten.

func CopyToDir added in v1.1.0

func CopyToDir(src, dst string) error

CopyToDir copies the src file to dst dir. All parent directories are created with permissions 0755.

Source file's read and execute permissions are preserved for everyone. Write permission is preserved for owner. Group and others cannot write. Existing file will be overwritten.

func IsValidFileName

func IsValidFileName(fileName string) bool

IsValidFileName checks if a file name is cross-platform compatible

func TrimFileExtension added in v1.1.0

func TrimFileExtension(fileName string) string

TrimFileExtension returns the file name without extension.

For example,

when input is xyz.exe, output is xyz

when input is xyz.tar.gz, output is xyz.tar

func WriteFile added in v1.3.0

func WriteFile(tempDir, path string, content []byte) (writeErr error)

WriteFile writes content to a temporary file and moves it to path. If path already exists and is a file, WriteFile overwrites it.

Parameters:

  • tempDir is the directory to create the temporary file. It should be in the same mount point as path. If tempDir is empty, the default directory for temporary files is used.
  • path is the destination file path.
  • content is the content to write.

Types

This section is empty.

Jump to

Keyboard shortcuts

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