// Rwalk walks the hierarchy from fid, with the walk path determined by paths
Rwalk walks the hierarchy from fid, with the walk path determined by paths
// Rwalk walks the hierarchy from fid with the walk path determined by paths
func (fs *fileServer) Rwalk(fid protocol.FID, newfid protocol.FID, names []string) ([]protocol.QID, error) {
	ctx := context.Background()
	parent, err := fs.getFile(fid)
	if err != nil {
		return nil, ErrFileNotFound
	}
	if len(names) == 0 {
		fs.setFile(newfid, parent)
		return []protocol.QID{}, nil
	}
	if parent.Type != icore.TDirectory {
		return nil, ErrWalkNoDir
	}
	qids := make([]protocol.QID, len(names))
	curr := parent
	for i, name := range names {
		if name == ".." {
			curr = curr.Parent
		} else {
			curr, err = fs.ipfs.Walk(ctx, curr, name)
			if err != nil {
				if i == 0 {
					return nil, err
				}
				return qids[:i], nil
			}
		}
		qids[i] = getQid(curr)
	}
	fs.setFile(newfid, curr)
	return qids, nil
}
func ( fs * fileServer ) Rwalk ( fid protocol . FID , newfid protocol . FID , names [ ] string ) ( [ ] protocol . QID , error ) { ctx := context . Background ( ) parent , err := fs . getFile ( fid ) if err != nil { return nil , ErrFileNotFound } if len ( names ) == 0 { fs . setFile ( newfid , parent ) return [ ] protocol . QID { } , nil } if parent . Type != icore . TDirectory { return nil , ErrWalkNoDir } qids := make ( [ ] protocol . QID , len ( names ) ) curr := parent for i , name := range names { if name == " " { curr = curr . Parent } else { curr , err = fs . ipfs . Walk ( ctx , curr , name ) if err != nil { if i == 0 { return nil , err } return qids [ : i ] , nil } } qids [ i ] = getQid ( curr ) } fs . setFile ( newfid , curr ) return qids , nil }
Rwalk walks the hierarchy from fid, with the walk path determined by paths
Rwalk walks the hierarchy from fid with the walk path determined by paths
// Lookup the parent fid // Clone fid - point to same entry // If the first element cannot be walked, return Rerror. // Otherwise return whatever much we have so far, // but newfid is not affected.