hdn file type added

This commit is contained in:
ed 2019-12-18 22:34:44 +01:00
parent f8e4bbfe64
commit 85d3812fee
1 changed files with 14 additions and 1 deletions

15
main.go
View File

@ -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":