+// Write implements io.Writer interface for FilePath
+func (fp *FilePath) Write(b []byte) (n int, err error) {
+ reader := bytes.NewReader(b)
+ err = binary.Read(reader, binary.BigEndian, &fp.ItemCount)
+ if err != nil && !errors.Is(err, io.EOF) {
+ return n, err
+ }
+ if errors.Is(err, io.EOF) {
+ return n, nil
+ }
+
+ scanner := bufio.NewScanner(reader)
+ scanner.Split(fileItemScanner)
+
+ for i := 0; i < int(binary.BigEndian.Uint16(fp.ItemCount[:])); i++ {
+ var fpi FilePathItem
+ scanner.Scan()
+
+ // Make a new []byte slice and copy the scanner bytes to it. This is critical to avoid a data race as the
+ // scanner re-uses the buffer for subsequent scans.
+ buf := make([]byte, len(scanner.Bytes()))
+ copy(buf, scanner.Bytes())
+
+ if _, err := fpi.Write(buf); err != nil {
+ return n, err
+ }
+ fp.Items = append(fp.Items, fpi)
+ }
+
+ return n, nil
+}
+
+// IsDropbox checks if a FilePath matches the special drop box folder type
+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")
+}