fs

package
v2.7.10 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2024 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateFile

func CreateFile(newpath string) (*os.File, error)

CreateFile creates a new file at newpath, returning an error if newpath already exists

func IsSpecialFSFromFileInfo added in v2.7.7

func IsSpecialFSFromFileInfo(st fs.FileInfo) (bool, error)

IsSpecialFSFromFileInfo determines if a file resides on a special file system (e.g. /proc, /dev/, /sys) based on its fs.FileInfo. The bool return value should be ignored if err is not nil.

func MoveFileWithReplacement added in v2.2.0

func MoveFileWithReplacement(src, dst string) error

MoveFileWithReplacement copies the file contents at `src` to `dst`. and deletes `src` on success.

If the file at `dst` already exists, it will be truncated and its contents overwritten.

func RenameFile

func RenameFile(oldpath, newpath string) error

RenameFile renames oldpath to newpath, returning an error if newpath already exists. If this function returns successfully, the contents of newpath will be identical to oldpath, and oldpath will be removed.

func RenameFileWithReplacement

func RenameFileWithReplacement(oldpath, newpath string) error

RenameFileWithReplacement will replace any existing file at newpath with the contents of oldpath. It works also if it the rename spans over several file systems.

If no file already exists at newpath, newpath will be created using the contents of oldpath. If this function returns successfully, the contents of newpath will be identical to oldpath, and oldpath will be removed.

func SyncDir

func SyncDir(dirName string) error

SyncDir flushes any file renames to the filesystem.

Types

type DiskStatus

type DiskStatus struct {
	All   uint64
	Used  uint64
	Free  uint64
	Avail uint64
}

DiskStatus is returned by DiskUsage

func DiskUsage

func DiskUsage(path string) (*DiskStatus, error)

DiskUsage returns disk usage of disk of path

type FileExistsError

type FileExistsError struct {
	// contains filtered or unexported fields
}

A FileExistsError is returned when an operation cannot be completed due to a file already existing.

func (FileExistsError) Error

func (e FileExistsError) Error() string

Jump to

Keyboard shortcuts

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