summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/pkg/sftp/request-attrs.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2018-03-04 23:46:13 +0100
committerWim <wim@42.be>2018-03-04 23:46:13 +0100
commit25a72113b122f984c904b24c4af23a1cba1eff45 (patch)
treef0fb7067d7c958d60ac964afa5b8d5fb79ebc339 /vendor/github.com/pkg/sftp/request-attrs.go
parent79c4ad5015bd2be47b32141c6d53f0d128bf865b (diff)
downloadmatterbridge-msglm-25a72113b122f984c904b24c4af23a1cba1eff45.tar.gz
matterbridge-msglm-25a72113b122f984c904b24c4af23a1cba1eff45.tar.bz2
matterbridge-msglm-25a72113b122f984c904b24c4af23a1cba1eff45.zip
Add vendor files for spf13/viper
Diffstat (limited to 'vendor/github.com/pkg/sftp/request-attrs.go')
-rw-r--r--vendor/github.com/pkg/sftp/request-attrs.go63
1 files changed, 63 insertions, 0 deletions
diff --git a/vendor/github.com/pkg/sftp/request-attrs.go b/vendor/github.com/pkg/sftp/request-attrs.go
new file mode 100644
index 00000000..0149d930
--- /dev/null
+++ b/vendor/github.com/pkg/sftp/request-attrs.go
@@ -0,0 +1,63 @@
+package sftp
+
+// Methods on the Request object to make working with the Flags bitmasks and
+// Attr(ibutes) byte blob easier. Use Pflags() when working with an Open/Write
+// request and AttrFlags() and Attributes() when working with SetStat requests.
+
+import "os"
+
+// Open packet pflags
+type pflags struct {
+ Read, Write, Append, Creat, Trunc, Excl bool
+}
+
+// testable constructor
+func newPflags(flags uint32) pflags {
+ return pflags{
+ Read: flags&ssh_FXF_READ != 0,
+ Write: flags&ssh_FXF_WRITE != 0,
+ Append: flags&ssh_FXF_APPEND != 0,
+ Creat: flags&ssh_FXF_CREAT != 0,
+ Trunc: flags&ssh_FXF_TRUNC != 0,
+ Excl: flags&ssh_FXF_EXCL != 0,
+ }
+}
+
+// Check bitmap/uint32 for Open packet pflag values
+func (r *Request) Pflags() pflags {
+ return newPflags(r.Flags)
+}
+
+// File attribute flags
+type aflags struct {
+ Size, UidGid, Permissions, Acmodtime bool
+}
+
+// testable constructor
+func newAflags(flags uint32) aflags {
+ return aflags{
+ Size: (flags & ssh_FILEXFER_ATTR_SIZE) != 0,
+ UidGid: (flags & ssh_FILEXFER_ATTR_UIDGID) != 0,
+ Permissions: (flags & ssh_FILEXFER_ATTR_PERMISSIONS) != 0,
+ Acmodtime: (flags & ssh_FILEXFER_ATTR_ACMODTIME) != 0,
+ }
+}
+
+// Check bitmap/uint32 for file attribute flags
+func (r *Request) AttrFlags(flags uint32) aflags {
+ return newAflags(r.Flags)
+}
+
+// File attributes
+type fileattrs FileStat
+
+// Return Mode wrapped in os.FileMode
+func (a fileattrs) FileMode() os.FileMode {
+ return os.FileMode(a.Mode)
+}
+
+// Parse file attributes byte blob and return them in object
+func (r *Request) Attributes() fileattrs {
+ fa, _ := getFileStat(r.Flags, r.Attrs)
+ return fileattrs(*fa)
+}