mirror of
https://github.com/vbatts/go-mtree.git
synced 2024-11-22 16:25:38 +00:00
keywords: add mode= (only octal first)
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
parent
211687bcc4
commit
ecdf381dd9
2 changed files with 10 additions and 1 deletions
10
keywords.go
10
keywords.go
|
@ -27,10 +27,16 @@ var (
|
||||||
"type",
|
"type",
|
||||||
"uid",
|
"uid",
|
||||||
"gid",
|
"gid",
|
||||||
|
"mode",
|
||||||
"link",
|
"link",
|
||||||
"nlink",
|
"nlink",
|
||||||
"time",
|
"time",
|
||||||
}
|
}
|
||||||
|
SetKeywords = []string{
|
||||||
|
"uid",
|
||||||
|
"gid",
|
||||||
|
"mode",
|
||||||
|
}
|
||||||
// KeywordFuncs is the map of all keywords (and the functions to produce them)
|
// KeywordFuncs is the map of all keywords (and the functions to produce them)
|
||||||
KeywordFuncs = map[string]KeywordFunc{
|
KeywordFuncs = map[string]KeywordFunc{
|
||||||
"size": sizeKeywordFunc, // The size, in bytes, of the file
|
"size": sizeKeywordFunc, // The size, in bytes, of the file
|
||||||
|
@ -41,6 +47,7 @@ var (
|
||||||
"gid": gidKeywordFunc, // The file group as a numeric value
|
"gid": gidKeywordFunc, // The file group as a numeric value
|
||||||
"nlink": nlinkKeywordFunc, // The number of hard links the file is expected to have
|
"nlink": nlinkKeywordFunc, // The number of hard links the file is expected to have
|
||||||
"uname": unameKeywordFunc, // The file owner as a symbolic name
|
"uname": unameKeywordFunc, // The file owner as a symbolic name
|
||||||
|
"mode": modeKeywordFunc, // The current file's permissions as a numeric (octal) or symbolic value
|
||||||
"cksum": cksumKeywordFunc, // The checksum of the file using the default algorithm specified by the cksum(1) utility
|
"cksum": cksumKeywordFunc, // The checksum of the file using the default algorithm specified by the cksum(1) utility
|
||||||
"md5": hasherKeywordFunc("md5", md5.New), // The MD5 message digest of the file
|
"md5": hasherKeywordFunc("md5", md5.New), // The MD5 message digest of the file
|
||||||
"md5digest": hasherKeywordFunc("md5digest", md5.New), // A synonym for `md5`
|
"md5digest": hasherKeywordFunc("md5digest", md5.New), // A synonym for `md5`
|
||||||
|
@ -65,6 +72,9 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
modeKeywordFunc = func(path string, info os.FileInfo) (string, error) {
|
||||||
|
return fmt.Sprintf("mode=%#o", info.Mode()), nil
|
||||||
|
}
|
||||||
sizeKeywordFunc = func(path string, info os.FileInfo) (string, error) {
|
sizeKeywordFunc = func(path string, info os.FileInfo) (string, error) {
|
||||||
return fmt.Sprintf("size=%d", info.Size()), nil
|
return fmt.Sprintf("size=%d", info.Size()), nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,6 @@ var (
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
println(string(data))
|
|
||||||
klist[i] = fmt.Sprintf("xattr.%s=%x", xlist[i], sha1.Sum(data))
|
klist[i] = fmt.Sprintf("xattr.%s=%x", xlist[i], sha1.Sum(data))
|
||||||
}
|
}
|
||||||
return strings.Join(klist, " "), nil
|
return strings.Join(klist, " "), nil
|
||||||
|
|
Loading…
Reference in a new issue