Skip to content

Useful Go abstractions for managing temporary directories and their content

License

Notifications You must be signed in to change notification settings

codequest-eu/directoryservice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

directoryservice codebeat badge GoDoc GoCover

Package directoryservice provides a useful abstraction for working with temporary directories and files they contain without the need to explicitly deal with the underlying OS's impementation. This can be useful for things like temporarily cloning Git repositories.

wercker status

Usage

import "github.com/codequest-eu/directoryservice"

func IsGoFile

func IsGoFile(fi os.FileInfo) bool

IsGoFile is a filter checking if a file is a Go file.

func IsNotTest

func IsNotTest(fi os.FileInfo) bool

IsNotTest is a filter checking if a file is not a Go test file.

type DirectoryService

type DirectoryService interface {
	// BasePath returns the base path for the DirectoryService.
	BasePath() string

	// FullPath returns a full path given a relative one.
	FullPath(string) string

	// Recurse recursively lists a directory and returns a list of paths to
	// files which pass all of the Filters.
	Recurse(string, ...Filter) ([]string, error)

	// FullPath returns a relative path given a full one.
	RelativePath(string) (string, error)

	// Cleanup removes the whole base directory. It invalidates the current
	// DirectoryService.
	Cleanup() error
}

DirectoryService takes responsibility of creating and removing local temporary directories.

func NewDirectoryService

func NewDirectoryService(path string) (DirectoryService, error)

NewDirectoryService returns a new instance of DirectoryService. If an empty path is passed a temporary directory is created.

type Filter

type Filter func(os.FileInfo) bool

Filter is a function which takes file metadata and decides whether we care about it.

About

Useful Go abstractions for managing temporary directories and their content

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages