diff options
| author | Jeff Halter <868228+jhalter@users.noreply.github.com> | 2022-05-29 10:03:19 -0700 |
|---|---|---|
| committer | Jeff Halter <868228+jhalter@users.noreply.github.com> | 2022-05-29 10:03:19 -0700 |
| commit | 7e2e07da8cc7985e773e619410801c6dd84afe8b (patch) | |
| tree | f3bedfce2ffaf9a5d309d10f25a17017e2c3522c /hotline/file_path.go | |
| parent | 003a743e6767b3041c3a8321566c3586d73b399a (diff) | |
Implement handling of special case Dropbox and Upload folders
Diffstat (limited to 'hotline/file_path.go')
| -rw-r--r-- | hotline/file_path.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/hotline/file_path.go b/hotline/file_path.go index 2e2e085..d5ddd23 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)), "uploads") +} + func (fp *FilePath) Len() uint16 { return binary.BigEndian.Uint16(fp.ItemCount[:]) } |