utils

package
v0.0.0-...-08f17c8 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: BSD-3-Clause Imports: 13 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetChecksumString

func GetChecksumString(checksum []byte) string

GetChecksumString returns string from checksum bytes

func GetDirname

func GetDirname(p string) string

GetDirname returns the dir of the path

func GetFileName

func GetFileName(p string) string

GetFileName returns the filename of the path

func GetIRODSZone

func GetIRODSZone(p string) (string, error)

GetIRODSZone returns the zone of the iRODS path

func GetParentDirs

func GetParentDirs(p string) []string

GetParentDirs returns all parent dirs

func GetPathDepth

func GetPathDepth(p string) int

GetPathDepth returns depth of the path "/" returns 0 "abc" returns -1 "/abc" returns 0 "/a/b" returns 1 "/a/b/c" returns 2

func GetRelativePath

func GetRelativePath(p1 string, p2 string) (string, error)

GetRelativePath returns relative path

func GetSHA1Sum

func GetSHA1Sum(str string) string

GetSHA1Sum returns sha1 check sum string

func IsAbsolutePath

func IsAbsolutePath(p string) bool

IsAbsolutePath returns true if the path is absolute

func JoinPath

func JoinPath(dirPath string, filePath string) string

JoinPath makes the path from dir and file paths

func MakeTimeToString

func MakeTimeToString(t time.Time) string

MakeTimeToString returns text represented time from time.Time

func ParseTime

func ParseTime(t string) (time.Time, error)

ParseTime returns time.Time from text represented time

func SplitPath

func SplitPath(p string) (string, string)

SplitPath splits the path into dir and file

func StackTraceFromPanic

func StackTraceFromPanic(logger *log.Entry)

Types

type Duration

type Duration time.Duration

Duration is a replacement of time.Duration that supports JSON

func (*Duration) MarshalJSON

func (d *Duration) MarshalJSON() ([]byte, error)

MarshalJSON ...

func (*Duration) UnmarshalJSON

func (d *Duration) UnmarshalJSON(b []byte) error

UnmarshalJSON ...

func (*Duration) UnmarshalYAML

func (d *Duration) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML ...

type FileBlockHelper

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

FileBlockHelper helps block/offset related calculation

func NewFileBlockHelper

func NewFileBlockHelper(blockSize int) *FileBlockHelper

func (*FileBlockHelper) GetBlockIDForOffset

func (helper *FileBlockHelper) GetBlockIDForOffset(offset int64) int64

GetBlockIDForOffset returns block index

func (*FileBlockHelper) GetBlockIDs

func (helper *FileBlockHelper) GetBlockIDs(offset int64, length int) []int64

GetBlockIDs returns all block ids

func (*FileBlockHelper) GetBlockRange

func (helper *FileBlockHelper) GetBlockRange(offset int64, length int, blockID int64) (int64, int)

GetBlockRange returns offset and length for given block, within given offset and length

func (*FileBlockHelper) GetBlockSize

func (helper *FileBlockHelper) GetBlockSize() int

GetBlockSize returns block size

func (*FileBlockHelper) GetBlockStartOffset

func (helper *FileBlockHelper) GetBlockStartOffset(blockID int64) int64

GetBlockStartOffset returns block start offset

func (*FileBlockHelper) GetFirstAndLastBlockID

func (helper *FileBlockHelper) GetFirstAndLastBlockID(offset int64, length int) (int64, int64)

GetFirstAndLastBlockID returns first and last block id

func (*FileBlockHelper) GetLastBlockID

func (helper *FileBlockHelper) GetLastBlockID(size int64) int64

GetLastBlockID returns the last block of the file

func (*FileBlockHelper) IsAlignedToBlockStart

func (helper *FileBlockHelper) IsAlignedToBlockStart(offset int64) bool

IsAligned checks if offset is aligned to block start

func (*FileBlockHelper) Max

func (helper *FileBlockHelper) Max(val1 int64, val2 int64) int64

Max returns max value between val1 and val2

func (*FileBlockHelper) Min

func (helper *FileBlockHelper) Min(val1 int64, val2 int64) int64

MinOffset returns min value between val1 and val2

Jump to

Keyboard shortcuts

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