]> git.r.bdr.sh - rbdr/mobius/blobdiff - hotline/file_path.go
Buffer file writes during upload
[rbdr/mobius] / hotline / file_path.go
index 2e2e085046a6269f5f577930ec7b7e1781d2c436..f7da29818e8bfc2489442609aeaf99f3316fac60 100644 (file)
@@ -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[:])
 }