path

package
v0.0.0-...-3c86364 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DirMaker

type DirMaker interface {
	Mkdir(ctx context.Context, path string) error
}

DirMaker defines interface for implementing directory creation in local filesystem and iRODS.

func NewDirMaker

func NewDirMaker(path PathInfo, config config.Configuration) DirMaker

NewDirMaker determines the path type and returns a corresponding implementation of the DirMaker interface.

type FileSystemDirMaker

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

FileSystemDirMaker implements the DirMaker for local filesystem.

func (FileSystemDirMaker) Mkdir

func (m FileSystemDirMaker) Mkdir(ctx context.Context, path string) error

Mkdir ensures the directory referred by the path is created.

type FileSystemScanner

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

FileSystemScanner implements the `Scanner` interface for a POSIX-compliant filesystem.

func (FileSystemScanner) CountFilesInDir

func (s FileSystemScanner) CountFilesInDir(ctx context.Context, dir string) int

func (FileSystemScanner) ScanMakeDir

func (s FileSystemScanner) ScanMakeDir(ctx context.Context, buffer int, dirmaker *DirMaker) chan string

ScanMakeDir gets a list of files iteratively under a file system `path`, and performs directory creation based on the implementation of the `dirmaker`.

The output is a string channel with the buffer size provided by the `buffer` argument. Each element of the channel refers to a file path. The channel is closed at the end of the scan.

type IrodsCollectionMaker

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

IrodsCollectionMaker implements the DirMaker for iRODS, using the `imkdir` system call.

func (IrodsCollectionMaker) Mkdir

func (m IrodsCollectionMaker) Mkdir(ctx context.Context, coll string) error

Mkdir ensures the iRODS collection referred by the path is created.

type IrodsCollectionScanner

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

IrodsCollectionScanner implements the `Scanner` interface for iRODS.

func (IrodsCollectionScanner) CountFilesInDir

func (s IrodsCollectionScanner) CountFilesInDir(ctx context.Context, dir string) int

func (IrodsCollectionScanner) ScanMakeDir

func (s IrodsCollectionScanner) ScanMakeDir(ctx context.Context, buffer int, dirmaker *DirMaker) chan string

ScanMakeDir gets a list of data objects iteratively under a iRODS collection `path`, and performs directory creation based on the implementation of `dirmaker`.

The output is a string channel with the buffer size provided by the `buffer` argument. Each element of the channel refers to an iRODS data object. The channel is closed at the end of the scan.

type PathInfo

type PathInfo struct {
	// Path is the path in question.
	Path string
	// PathType is the namespace type of the path.
	Type PathType
	// Mode is the `os.FileMode` of the path.
	Mode os.FileMode
	// Size
	Size int64
	// contains filtered or unexported fields
}

PathInfo defines a data structure of the path information.

func GetPathInfo

func GetPathInfo(ctx context.Context, path string) (PathInfo, error)

GetPathInfo resolves the PathInfo of the given path.

func (PathInfo) CountFiles

func (p PathInfo) CountFiles(ctx context.Context) int

func (PathInfo) GetChecksum

func (p PathInfo) GetChecksum() string

func (PathInfo) SameAs

func (p PathInfo) SameAs(ctx context.Context, o PathInfo) bool

type PathType

type PathType int

PathType represents the namespace type a path is referring to.

const (
	// TypeFileSystem is the namespace type for local filesystem.
	TypeFileSystem PathType = iota
	// TypeIrods is the the namespace type for iRODS.
	TypeIrods
)

type Scanner

type Scanner interface {
	// ScanMakeDir gets a list of file-like objects iteratively under the given path, and
	// performs mkdir-like operations when the iteration visits a directory-like object.
	//
	// How the iteration is done depends on the implementation. How the mkdir-like operation is
	// performed is also based on the implementation of the `dirmaker`.  Set the `dirmaker` to
	// `nil` to skip the directory making operation.
	//
	// For example, it can be that the Scanner is implemented to loop over a local filesystem using
	// the `filepath.Walk`, while the `dirmaker` is implemented to create a remote iRODS collection.
	ScanMakeDir(ctx context.Context, buffer int, dirmaker *DirMaker) chan string

	// CountFilesInDir counts number of files in a given directory
	CountFilesInDir(ctx context.Context, dir string) int
}

Scanner defines the interface for scanning files iteratively from a namespace `path`.

func NewScanner

func NewScanner(path PathInfo) Scanner

NewScanner determines the path type and returns a corresponding implementation of the Scanner interface.

Jump to

Keyboard shortcuts

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