From 85d3812fee7f1937f808a871c48633e88bab741b Mon Sep 17 00:00:00 2001 From: ed Date: Wed, 18 Dec 2019 22:34:44 +0100 Subject: [PATCH] hdn file type added --- main.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index a41934d..0318182 100644 --- a/main.go +++ b/main.go @@ -13,13 +13,14 @@ import ( "regexp" "strings" "syscall" -// "github.com/h2non/filetype" + "github.com/h2non/filetype" "golang.org/x/crypto/ssh/terminal" ) var debug bool = true var FileName string var HDNFhead []byte = []byte("HDNF") +var hdnfType = filetype.NewType("hdn","application/hns") func checkErr(err error) { if err != nil { @@ -137,14 +138,26 @@ func headerRemove(data []byte) []byte { return bytes.TrimPrefix(data,HDNFhead) } +func hdnfMatcher(buf []byte) bool { + return len(buf) > 1 && buf[0] == 0x48 && buf[1] == 0x44 && buf[2] == 0x4e && buf[3] == 0x46 +} + func main() { FileName = readFn() + filetype.AddMatcher(hdnfType, hdnfMatcher) fn := FileName fmt.Println(fn) //data := file2data(fn) //fType, _ := filetype.Get(data) //fmt.Println(fType.Extension) //os.Exit(0) + buf := file2data(FileName) + if filetype.IsType(buf,hdnfType) { + fmt.Println("this is an hidden file") + } else { + fmt.Println("not hidden") + } + os.Exit(0) mode := getMode() switch mode { case "h":