/*
Exists returns true if the file exists. Calls t.Error if something goes wrong while
checking.
*/
430109
func Exists(t TestReporter, path string) bool {
	exists, err := afero.Exists(appFs, path)
	if err != nil {
		t.Error("Something went wrong when checking if "+path+"exists!", err)
	}
	return exists
}
949971
func (b *Bucket) Exists(path string) (exists bool, err error) {
	for attempt := attempts.Start(); attempt.Next(); {
		req := &request{
			method: "HEAD",
			bucket: b.Name,
			path:   path,
		}
		err = b.Client.prepare(req)
		if err != nil {
			return
		}

		resp, err := b.Client.run(req, nil)

		if shouldRetry(err) && attempt.HasNext() {
			continue
		}

		if err != nil {
			// We can treat a 403 or 404 as non existence
			if e, ok := err.(*Error); ok && (e.StatusCode == 403 || e.StatusCode == 404) {
				return false, nil
			}
			return false, err
		}

		if resp.StatusCode/100 == 2 {
			exists = true
		}
		if resp.Body != nil {
			resp.Body.Close()
		}
		return exists, err
	}
	return false, fmt.Errorf("OSS Currently Unreachable")
}
258984
func (s *Set) Exists(v string) bool {
	pos := sort.SearchStrings(s.items, v)
	return pos < len(s.items) && s.items[pos] == v
}
573064
func (s *MockStore) Exists(key string) (bool, error) {
	_, ok := s.db[key]
	return ok, nil
}
972914
func (d *Driver) Exists(id string) bool {
	path := path.Join(virtPath, id)

	_, err := os.Stat(path)

	if err == nil {
		return true
	} else {
		return false
	}
}
840234
func (c *Connection) Exists(path string) (bool, error) {
	c.RLock()
	defer c.RUnlock()
	if err := c.isClosed(); err != nil {
		return false, err
	}
	return c.exists(path)
}
406149
func (b *Bucket) Exists(path string) (exists bool, err error) {
	req := &request{
		method: "HEAD",
		bucket: b.Name,
		path:   path,
	}
	err = b.S3.prepare(req)
	if err != nil {
		return
	}
	for attempt := b.S3.AttemptStrategy.Start(); attempt.Next(); {
		resp, err := b.S3.run(context.Background(), req, nil)

		if shouldRetry(err) && attempt.HasNext() {
			continue
		}

		if err != nil {
			// We can treat a 403 or 404 as non existence
			if e, ok := err.(*Error); ok && (e.StatusCode == 403 || e.StatusCode == 404) {
				return false, nil
			}
			return false, err
		}

		if resp.StatusCode/100 == 2 {
			exists = true
		}
		return exists, err
	}
	return false, fmt.Errorf("S3 Currently Unreachable")
}
443115
func (m *InMem) Exists(ctx context.Context, name string) bool {
	m.Lock()
	defer m.Unlock()

	_, found := m.data[name]
	return found
}
1010378
func (s *SvcManager) Exists(name string, conf common.Conf) (bool, error) {
	return false, nil
}
303108
func (s *Store) Exists(ctx context.Context, name string) bool {
	return s.storage.Exists(ctx, s.passfile(name))
}
1132514
func (s *StoreToDaemonSetLister) Exists(ds *extensions.DaemonSet) (bool, error) {
	_, exists, err := s.Store.Get(ds)
	if err != nil {
		return false, err
	}
	return exists, nil
}
960497
func (doc *Document) Exists() ([]byte, error) {
	// Use the get operation to get it.
	body, err := doc.Db.Req.Get(doc.Id, nil)

	if err != nil {
		return nil, err
	} else {
		result := &struct {
			Error string `json:"error"`
			Ok    bool   `json:"ok"`
			Id    string `json:"_id"`
			Rev   string `json:"_rev"`
		}{}
		err = json.Unmarshal(body, result)
		if err != nil {
			return nil, err
		}

		if result.Error != "" {
			return nil, errors.New(result.Error)
		}
		doc.Id = result.Id
		doc.Rev = result.Rev
	}
	return body, nil
}
610359
func (c *Collection) Exists(id string) (bool, error) {
	t := c.pool.NewTransaction()
	exists := false
	t.Exists(c, id, &exists)
	if err := t.Exec(); err != nil {
		return false, err
	}
	return exists, nil
}
1171981
func (d *PortRuleDNS) Exists(rules L7Rules) bool {
	for _, existingRule := range rules.DNS {
		if d.Equal(existingRule) {
			return true
		}
	}

	return false
}
791764
func FileExists(filePath string) (bool, int64, error) {
	fileInfo, err := os.Stat(filePath)
	if os.IsNotExist(err) {
		return false, 0, nil
	}
	if err != nil {
		return false, 0, errors.Wrapf(err, "error checking if file [%s] exists", filePath)
	}
	return true, fileInfo.Size(), nil
}
362199
func (z *zookeeperKV) exists(key string) (bool, error) {
	key = z.domain + normalize(key)
	exists, _, err := z.client.Exists(key)
	if err != nil {
		return false, err
	}
	return exists, nil
}
400507
func (r *Response) fileExists(file string) bool {
	if _, err := os.Stat(file); err == nil {
		return true
	}

	r.Status = http.StatusNotFound
	log.Warnf("cannot find %s file", file)
	return false
}