fsio

package module
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2021 License: MIT Imports: 4 Imported by: 2

README

fsio

File system io support functions that support "~" HOME paths

Status

Status Build Status Release Coveralls GoReportCard Go Doc Conventional Commits

Installation

go get -u https://github.com/nehemming/fsio

or clone this repo to your local machine using

git clone https://github.com/nehemming/fsio

This project requires Go 1.15 or newer and supports modules.

Key features

  • Support functions to help interact with file systems
  • Supports expansion of paths starting with ~
  • Create nested directories with ~ support
  • Read and write files to / from buffers with ~ support
  • Support expanding file paths relative to another file

Acknowledgments

Contributing

We would welcome contributions to this project. Please read our CONTRIBUTION file for further details on how you can participate or report any issues.

License

FOSSA Status

MIT

Documentation

Overview

Package fsio provides so file system helper functions and types

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Chdir added in v0.6.0

func Chdir(dir string) error

Chdir changes the current working directory to the named directory. Directory paths starting with ~ will be expanded relative to the home folder.

func CreateFileDirectory

func CreateFileDirectory(filename string, dirMode os.FileMode) error

CreateFileDirectory creates a file's parent directories as necessary.

func ExpandFilePath

func ExpandFilePath(path string) (string, error)

ExpandFilePath expadas a file path to an absolute path. This function handles home directory '~' specifications.

func MakeAbsFromRelativeToFile

func MakeAbsFromRelativeToFile(path, relFile string) (string, error)

MakeAbsFromRelativeToFile makes path into an absolute path, using relfile as sibling file location to the relative base of the path.

func ReadFileFromPath

func ReadFileFromPath(filename string) ([]byte, error)

ReadFileFromPath expands the directory path and then reads the file specified.

func WriteFileToPath

func WriteFileToPath(filename string, buf []byte, modes FileModes) error

WriteFileToPath writes a file to the filename specified. Function expand the path (including ~ substitution) and creates as necessary the parent directoried.

Types

type FileModes

type FileModes struct {
	FileMode os.FileMode
	DirMode  os.FileMode
}

FileModes contains filer and director permissions.

func NewFileModes

func NewFileModes() FileModes

NewFileModes creates a new FileModes struct with default file permissions.

Jump to

Keyboard shortcuts

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