func readStat(s wire.SyncScanner) (entry *DirEntry, err error) { mode, err := s.ReadFileMode() if err != nil { err = util.WrapErrf(err, "error reading file mode: %v", err) return } size, err := s.ReadInt32() if err != nil { err = util.WrapErrf(err, "error reading file size: %v", err) return } mtime, err := s.ReadTime() if err != nil { err = util.WrapErrf(err, "error reading file time: %v", err) return } // adb doesn't indicate when a file doesn't exist, but will return all zeros. // Theoretically this could be an actual file, but that's very unlikely. if mode == os.FileMode(0) && size == 0 && mtime == zeroTime { return nil, util.Errorf(util.FileNoExistError, "file doesn't exist") } entry = &DirEntry{ Mode: mode, Size: size, ModifiedAt: mtime, } return }
func readNextDirListEntry(s wire.SyncScanner) (entry *DirEntry, done bool, err error) { id, err := s.ReadOctetString() if err != nil { return } if id == "DONE" { done = true return } else if id != "DENT" { err = fmt.Errorf("error reading dir entries: expected dir entry ID 'DENT', but got '%s'", id) return } mode, err := s.ReadFileMode() if err != nil { err = fmt.Errorf("error reading dir entries: error reading file mode: %v", err) return } size, err := s.ReadInt32() if err != nil { err = fmt.Errorf("error reading dir entries: error reading file size: %v", err) return } mtime, err := s.ReadTime() if err != nil { err = fmt.Errorf("error reading dir entries: error reading file time: %v", err) return } name, err := s.ReadString() if err != nil { err = fmt.Errorf("error reading dir entries: error reading file name: %v", err) return } done = false entry = &DirEntry{ Name: name, Mode: mode, Size: size, ModifiedAt: mtime, } return }