// list the objects into the function supplied
//
// dir is the starting directory, "" for root
//
// Set recurse to read sub directories
list the objects into the function supplied

dir is the starting directory, "" for root

Set recurse to read sub directories
// list the objects into the function supplied // // dir is the starting directory " " for root // // Set recurse to read sub directories
func (f *Fs) list(ctx context.Context, dir string, recurse bool, fn listFn) error {
	prefix := f.root
	if dir != "" {
		prefix += dir + "/"
	}
	delimiter := ""
	if !recurse {
		delimiter = "/"
	}
	maxLimit := int(listLimitSize)
	var marker *string
	for {
		bucketInit, err := f.svc.Bucket(f.bucket, f.zone)
		if err != nil {
			return err
		}
		req := qs.ListObjectsInput{
			Delimiter: &delimiter,
			Prefix:    &prefix,
			Limit:     &maxLimit,
			Marker:    marker,
		}
		resp, err := bucketInit.ListObjects(&req)
		if err != nil {
			if e, ok := err.(*qsErr.QingStorError); ok {
				if e.StatusCode == http.StatusNotFound {
					err = fs.ErrorDirNotFound
				}
			}
			return err
		}
		rootLength := len(f.root)
		if !recurse {
			for _, commonPrefix := range resp.CommonPrefixes {
				if commonPrefix == nil {
					fs.Logf(f, "Nil common prefix received")
					continue
				}
				remote := *commonPrefix
				if !strings.HasPrefix(remote, f.root) {
					fs.Logf(f, "Odd name received %q", remote)
					continue
				}
				remote = remote[rootLength:]
				if strings.HasSuffix(remote, "/") {
					remote = remote[:len(remote)-1]
				}
				err = fn(remote, &qs.KeyType{Key: &remote}, true)
				if err != nil {
					return err
				}
			}
		}
		for _, object := range resp.Keys {
			key := qs.StringValue(object.Key)
			if !strings.HasPrefix(key, f.root) {
				fs.Logf(f, "Odd name received %q", key)
				continue
			}
			remote := key[rootLength:]
			err = fn(remote, object, false)
			if err != nil {
				return err
			}
		}
		if resp.NextMarker == nil || *resp.NextMarker == "" {
			break
		} else {
			marker = resp.NextMarker
		}
	}
	return nil
}
func ( f * Fs ) list ( ctx context . Context , dir string , recurse bool , fn listFn ) error { prefix := f . root if dir != " " { prefix += dir + " " } delimiter := " " if ! recurse { delimiter = " " } maxLimit := int ( listLimitSize ) var marker * string for { bucketInit , err := f . svc . Bucket ( f . bucket , f . zone ) if err != nil { return err } req := qs . ListObjectsInput { Delimiter : & delimiter , Prefix : & prefix , Limit : & maxLimit , Marker : marker , } resp , err := bucketInit . ListObjects ( & req ) if err != nil { if e , ok := err . ( * qsErr . QingStorError ) ; ok { if e . StatusCode == http . StatusNotFound { err = fs . ErrorDirNotFound } } return err } rootLength := len ( f . root ) if ! recurse { for _ , commonPrefix := range resp . CommonPrefixes { if commonPrefix == nil { fs . Logf ( f , " " ) continue } remote := * commonPrefix if ! strings . HasPrefix ( remote , f . root ) { fs . Logf ( f , " " , remote ) continue } remote = remote [ rootLength : ] if strings . HasSuffix ( remote , " " ) { remote = remote [ : len ( remote ) - 1 ] } err = fn ( remote , & qs . KeyType { Key : & remote } , true ) if err != nil { return err } } } for _ , object := range resp . Keys { key := qs . StringValue ( object . Key ) if ! strings . HasPrefix ( key , f . root ) { fs . Logf ( f , " " , key ) continue } remote := key [ rootLength : ] err = fn ( remote , object , false ) if err != nil { return err } } if resp . NextMarker == nil || * resp . NextMarker == " " { break } else { marker = resp . NextMarker } } return nil }
list the objects into the function supplied
list the objects into the function supplied
// FIXME need to implement ALL loop // Use NextMarker if set, otherwise use last Key //marker = resp.Keys[len(resp.Keys)-1].Key