higgs

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2022 License: MIT Imports: 4 Imported by: 2

README

higgs

A tiny cross-platform Go library to hide or unhide files and directories.

Supported OSs: All unix based OSs (Tested on Ubuntu, MacOS), Windows

unix windows codecov GitHub release
Go Reference GitHub go.mod Go version Go Report Card GitHub Mentioned in Awesome Go

Installation

$ go get github.com/dastoori/higgs

Usage

package main

import (
	"fmt"
	"github.com/dastoori/higgs"
)

func main() {
	path := "foo.txt"

	// Hiding a file
	newPath, err := higgs.Hide(path)
	// NOTE: On Unix after hiding the file the file name
	// will be changed to `.foo.txt` and `newPath` contains
	// the new file name

	if err != nil {
		fmt.Println(err)
	}

	// Unhiding a file
	newPath, err = higgs.Unhide(newPath)
	
	if err != nil {
		fmt.Println(err)
	}

	// Setting unix overwrite option (disable by default)
	fh := NewFileHide(".bar.txt", UnixOverwriteOption(true))

	// NOTE: On Unix if a `bar.txt` file exists, it will be
	// overwritten after unhiding `.bar.txt`
	err := fh.Unhide()
	
	if err != nil {
		fmt.Println(err)
	}

	// NOTE: `fh.Path` contains the new file name
}

License

MIT

Documentation

Overview

higgs is a tiny cross-platform Go library to hide or unhide files and directories

**Supported OSs:** All unix based OSs (Tested on Ubuntu, MacOS), Windows

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Hide

func Hide(path string) (string, error)

Hide makes file or directory hidden

func IsHidden

func IsHidden(path string) (bool, error)

IsHidden checks whether "path" is hidden or not

func Unhide

func Unhide(path string) (string, error)

Unhide makes file or directory unhidden

Types

type FileHide

type FileHide struct {
	Path          string
	UnixOverwrite bool
}

FileHide object that holds higgs configs

func NewFileHide

func NewFileHide(path string, options ...FileHideOption) *FileHide

NewFileHide makes new FileHide instance

func (*FileHide) Hide

func (fh *FileHide) Hide() error

Hide makes file or directory hidden

func (*FileHide) IsHidden

func (fh *FileHide) IsHidden() (bool, error)

IsHidden checks whether "FileHide.Path" is hidden or not

func (*FileHide) Unhide

func (fh *FileHide) Unhide() error

Unhide makes file or directory unhidden

type FileHideOption

type FileHideOption func(*FileHide)

FileHideOption type that holds a FileHide option

func UnixOverwriteOption

func UnixOverwriteOption(value bool) FileHideOption

UnixOverwriteOption allows the renaming process to overwrite existing file (unix option)

type FileHidener

type FileHidener interface {
	IsHidden() (bool, error)
	Hide() error
	Unhide() error
}

FileHidener implements the FileHide methods

Jump to

Keyboard shortcuts

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