util

package
v0.2.0-alpha-test Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2020 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const DirPermissions = os.ModeDir | 0775

DirPermissions are the default permission bits we apply to directories.

Variables

This section is empty.

Functions

func AppendToDoubleSlice

func AppendToDoubleSlice(dest [][]string, entries [][]string) (newdest [][]string)

AppendToDoubleSlice appends all string slices from entries to dest and returns a new object holding the slice of string slices

func ChromeTime

func ChromeTime(chrometime interface{}) (string, error)

ChromeTime converts webkit/chrome microsecond timestamps to UTC strings of ISO8601 format

func CocoaTime

func CocoaTime(seconds int64) (string, error)

CocoaTime converts cocoa webkit DB timestamp to ISO8601, UTC format

func CopyFile

func CopyFile(from string, to string, mode os.FileMode) error

CopyFile copies a file from 'from' to 'to', with an attempt to perform a copy & rename to avoid chaos if anything goes wrong partway.

func CopyFiles

func CopyFiles(fileglobnames []string, destfolder string, rootTargetPath string) ([]string, error)

CopyFiles globs a list of filenames from fileglobnames and copies those files to the destfolder. Returns a list of the paths of copied files and an error (nil if no error) fileglobnames is case sensitive and must be a slice of strings formatted as glob ex. Users\\*\\OneDrive MINUS the rootTargetPath destfolder must be relative to your current Orion execution folder rootTargetPath specifies the prefix of the fileglobnames

func DBColumnNames

func DBColumnNames(dbfile, tablename string) ([]string, error)

DBColumnNames returns a slice of strings representing column headers for input tablename of dbfile

func EntryFromMap

func EntryFromMap(m map[string]string, headers []string) ([]string, error)

EntryFromMap returns a slice of strings based on input map m and associated with and in order by headers/keys

func Exists

func Exists(path string) (bool, error)

Exists returns whether the given file or directory exists

func FileExists

func FileExists(filename string) bool

FileExists returns true if the given path exists and is a file.

func FileExtension

func FileExtension(filepath string) string

FileExtension split filepath string to return the file extension

func GetPrintableString

func GetPrintableString(str string) string

GetPrintableString returns a string where non-printables in str are omitted

func GetUsernameFromPath

func GetUsernameFromPath(path string) string

GetUsernameFromPath returns the last entry of a filepath split by delimiter, typically username for a username path

func Glob

func Glob(glob string, targetPath string) []string

func InitializeMapToEmptyString

func InitializeMapToEmptyString(m map[string]string, headers []string) map[string]string

InitializeMapToEmptyString returns a map that is initialized to empty string for given headers

func InterfaceToString

func InterfaceToString(i interface{}) (string, error)

InterfaceToString uses type assertion to convert input interface to string if possible

func IsDirectory

func IsDirectory(path string) bool

IsDirectory checks if a given path is a directory

func IsSymlink(filename string) bool

IsSymlink returns true if the given path exists and is a symlink.

func JSONGetValueFromKey

func JSONGetValueFromKey(j interface{}, key string) (interface{}, error)

JSONGetValueFromKey takes in an interface representing json data (map[string]interface) and a key, and returns the value for that key if it finds it

func MapToJSONString

func MapToJSONString(m map[string]interface{}) string

MapToJSONString converts an input map[string]interface{} to an appropraite json string for output writing

func MultiMultiGlob

func MultiMultiGlob(sliceGlob []string, targetPaths []string) []string

MultiMultiGlob returns a list of globbed strings based on input list of patterns for an input list of target paths

func Multiglob

func Multiglob(sliceGlob []string, targetPath string) []string

Multiglob returns a list of globbed strings based on input list of patterns

func NewOrionLogger

func NewOrionLogger(logFlag string, orionRuntime string, outputPath string) (*zap.Logger, *os.File, error)

NewOrionLogger returns an instance of a Zap logger configured with logFlag level, name of orionRuntime, and outputPath

func PathExists

func PathExists(filename string) bool

PathExists returns true if the given path exists, as a file or a directory.

func Prepend

func Prepend(dest []string, value string) []string

Prepend to slice

func QueryDB

func QueryDB(dbfile string, query string, queryHeaders []string, forensic bool) ([][]string, error)

QueryDB returns an array of entries(string array) ordered by queryHeaders

func SliceContainsString

func SliceContainsString(slice []string, str string) bool

SliceContainsString outputs true if slice contains str

func UnsafeEntryFromMap

func UnsafeEntryFromMap(m interface{}, headers []string) ([]string, error)

UnsafeEntryFromMap returns a slice of strings in order of the header

func UnsafeQueryDB

func UnsafeQueryDB(dbfile, query string) ([][]string, error)

func UnsafeQueryDBToMap

func UnsafeQueryDBToMap(dbfile, query string) ([]map[string]interface{}, error)

func WriteFile

func WriteFile(fromFile io.Reader, to string, mode os.FileMode) error

WriteFile writes data from a reader to the file named 'to', with an attempt to perform a copy & rename to avoid chaos if anything goes wrong partway.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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