cfs

package
v0.0.0-...-f5c3557 Latest Latest
Warning

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

Go to latest
Published: May 2, 2018 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package cfs implements some extra filesystem utilities

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChangeExt

func ChangeExt(path, ext string) string

ChangeExt changes the extension on the given file to the given extension. If there is no previous extension, the new extension is appended to the path.

func Copy

func Copy(src, dst string) error

Copy copies a file from src to dst.

func Create

func Create(path string) (*os.File, error)

Create creates the given file by ensuring that is parent directories exist, then it creates the file.

func CreateParents

func CreateParents(path string) error

CreateParents creates all parents of the given file

func DirExists

func DirExists(path string) (bool, error)

DirExists checks if a directory exists, taking care of all of the wonkiness from os.Stat().

func DropExt

func DropExt(path string) string

DropExt is a shortcut for ChangeExt(path, "")

func FileExists

func FileExists(path string) (bool, error)

FileExists checks if a file exists, taking care of all of the wonkiness from os.Stat().

func FindDirInParents

func FindDirInParents(dir string) (path string, err error)

FindDirInParents climbs the directory tree, from the current directory to the root, looking for a directory with the given name at each level. If found, its absolute path is returned.

func FindInParents

func FindInParents(file string) (path string, err error)

FindInParents climbs the directory tree, from the current directory to the root, looking for a file with the given name at each level. If found, its absolute path is returned.

func ImportPath

func ImportPath(absPath string, isDir bool) (string, error)

ImportPath takes the given absolute path and returns the package that contains the file, in "github.com/iheartradio/cog" form. If !isDir, then the final path element is assumed to be a file and is stripped from the package name.

func TempFile

func TempFile(prefix, ext string) (f *os.File, err error)

TempFile creates a new temporary file in /tmp/ (or equivalent) with the given prefix and, unlike ioutil.TempFile, extension.

func TempFileIn

func TempFileIn(dir, prefix, ext string) (f *os.File, err error)

TempFileIn creates a new temporary file in the given directory with the given prefix and, unlike ioutil.TempFile, extension.

func Write

func Write(path string, c []byte) error

Write creates the file at the given path (using Create()), then writes the given contents to the file.

Types

This section is empty.

Jump to

Keyboard shortcuts

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