X-Git-Url: https://git.r.bdr.sh/rbdr/mobius/blobdiff_plain/92a7e455a347e5be7fb69b6846b9f27ca698ae12..4c24568a917fb84c429411f12e096a64222a1566:/hotline/file_path.go diff --git a/hotline/file_path.go b/hotline/file_path.go index 2e2e085..f7da298 100644 --- a/hotline/file_path.go +++ b/hotline/file_path.go @@ -5,6 +5,7 @@ import ( "encoding/binary" "errors" "path" + "strings" ) const pathSeparator = "/" // File path separator TODO: make configurable to support Windows @@ -31,6 +32,7 @@ type FilePath struct { } const minFilePathLen = 2 + func (fp *FilePath) UnmarshalBinary(b []byte) error { if b == nil { return nil @@ -53,6 +55,22 @@ func (fp *FilePath) UnmarshalBinary(b []byte) error { return nil } +func (fp *FilePath) IsDropbox() bool { + if fp.Len() == 0 { + return false + } + + return strings.Contains(strings.ToLower(string(fp.Items[fp.Len()-1].Name)), "drop box") +} + +func (fp *FilePath) IsUploadDir() bool { + if fp.Len() == 0 { + return false + } + + return strings.Contains(strings.ToLower(string(fp.Items[fp.Len()-1].Name)), "upload") +} + func (fp *FilePath) Len() uint16 { return binary.BigEndian.Uint16(fp.ItemCount[:]) }