Skip to content

Latest commit

 

History

History
70 lines (51 loc) · 2.1 KB

README.md

File metadata and controls

70 lines (51 loc) · 2.1 KB

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