// Read returns the decoded configuration file, or an error. Fields are separated by 4 colons. ("::::")
548200
func Read(secustom string) (config string, err error) {
	// This is the default encoded-but-not-safe blank password

	naclKey := new([keySize]byte)
	copy(naclKey[:], pad[:keySize])
	nonce := new([nonceSize]byte)
	in, err := ioutil.ReadFile(returnHome() + "/." + secustom)
	if err != nil {
		return "", err
	}
	copy(nonce[:], in[:nonceSize])
	configbytes, ok := secretbox.Open(nil, in[nonceSize:], nonce, naclKey)
	if ok {
		return string(configbytes), nil
	}

	// The blank password didn't work. Ask the user via speakeasy
	userKey, err := speakeasy.Ask("Password: ")

	key := []byte(userKey)
	key = append(key, pad...)
	naclKey = new([keySize]byte)
	copy(naclKey[:], key[:keySize])
	nonce = new([nonceSize]byte)
	in, err = ioutil.ReadFile(returnHome() + "/." + secustom)
	if err != nil {
		return "", err
	}
	copy(nonce[:], in[:nonceSize])
	configbytes, ok = secretbox.Open(nil, in[nonceSize:], nonce, naclKey)
	if !ok {
		return "", errors.New("Could not decrypt the config file. Wrong password?")
	}

	return string(configbytes), nil

}
900553
func (r *errorReader) Read(b []byte) (int, error) {
	if r.err != nil {
		return 0, r.err
	}
	var n int
	n, r.err = r.r.Read(b)
	return n, r.err
}
540645
func (t *PosixParser) Read() ([]byte, error) {
	buf := make([]byte, maxReadBytes)
	n, err := syscall.Read(t.fd, buf)
	if err != nil {
		return []byte{}, err
	}
	return buf[:n], nil
}
688530
func (d *Decoder) Read(p []byte) (int, error) {
	if d.stream == nil {
		return 0, errors.New("no input has been initialized")
	}
	var n int
	for {
		if len(d.current.b) > 0 {
			filled := copy(p, d.current.b)
			p = p[filled:]
			d.current.b = d.current.b[filled:]
			n += filled
		}
		if len(p) == 0 {
			break
		}
		if len(d.current.b) == 0 {
			// We have an error and no more data
			if d.current.err != nil {
				break
			}
			d.nextBlock()
		}
	}
	if len(d.current.b) > 0 {
		// Only return error at end of block
		return n, nil
	}
	if d.current.err != nil {
		d.drainOutput()
	}
	if debug {
		println("returning", n, d.current.err, len(d.decoders))
	}
	return n, d.current.err
}
1134547
func (db *Storage) Read(ctxt Context, val interface{}, columns ...string) error {
	ctxt = debugContext(ctxt)
	t, _, err := db.findType(val, "Read")
	if err != nil {
		return err
	}

	var buf bytes.Buffer
	var args, scanargs []interface{}
	rval := reflect.ValueOf(val).Elem()

	want := make(map[string]bool)
	for _, name := range columns {
		want[name] = true
	}

	fmt.Fprintf(&buf, "select ")
	sep := ""
	var fixes []func()
	for _, col := range t.fields {
		if !want[col.name] && !want["ALL"] {
			continue
		}
		delete(want, col.name)
		if col.key {
			continue // already set
		}
		fmt.Fprintf(&buf, "%s%q", sep, col.name)
		sep = ", "
		scanargs = append(scanargs, rval.FieldByIndex(col.index).Addr().Interface())
		if col.utf8 {
			fixes = append(fixes, func() {
				v := rval.FieldByIndex(col.index)
				s := v.String()
				if !utf8.ValidString(s) {
					v.SetString(string([]rune(s)))
				}
			})
		}
	}
	if sep == "" {
		// nothing to select, but want to provide error if not there.
		// select count of rows.
		fmt.Fprintf(&buf, "count(*)")
		scanargs = append(scanargs, new(int))
	}

	delete(want, "ALL")
	if len(want) != 0 {
		// some column wasn't found
		for _, name := range columns {
			if want[name] {
				return fmt.Errorf("unknown column %q", name)
			}
		}
	}

	fmt.Fprintf(&buf, " from %q where ", t.name)
	sep = ""
	for _, col := range t.fields {
		if !col.key {
			continue
		}
		fmt.Fprintf(&buf, "%s%q = ?", sep, col.name)
		sep = " and "
		args = append(args, rval.FieldByIndex(col.index).Interface())
	}

	rows, err := ctxt.Query(buf.String(), args...)
	if err != nil {
		return err
	}
	defer rows.Close()

	if !rows.Next() {
		if err := rows.Err(); err != nil {
			return err
		}
		return ErrNotFound
	}

	if err := rows.Scan(scanargs...); err != nil {
		return err
	}

	for _, fix := range fixes {
		fix()
	}

	return nil
}
47188
func (b *MemFile) Read(p []byte) (n int, err error) {
	b.mutex.RLock()
	n, err = b.Buffer.Read(p)
	b.mutex.RUnlock()
	return
}
1202903
func (f *HttpFile) Read(p []byte) (int, error) {

	n, err := f.ReadAt(p, f.pos)
	if n > 0 {
		f.pos += int64(n)
	}

	DebugLog(f.Debug).Println("Read", n, err)
	return n, err
}
873621
func (u *UTF8Reader) Read(p []byte) (n int, err error) {
	n, err = u.Source.Read(p)

	accepted := 0
	s, c := u.state, u.codep
	for i := 0; i < n; i++ {
		c, s = decode(s, c, p[i])
		if s == utf8Reject {
			u.state = s
			return accepted, ErrInvalidUTF8
		}
		if s == utf8Accept {
			accepted = i + 1
		}
	}
	u.state, u.codep = s, c
	u.accepted = accepted

	return
}
360954
func Read(path string) (Config, error) {
	c, err := defaultConfig()

	if err != nil {
		return Config{}, errors.WithMessage(err, "initializing default config")
	}

	c, err = readPath(c, path)
	if err != nil {
		return Config{}, err
	}

	for _, c := range []converter{&c.API, &c.Log, &c.Timeout, &c.FeedManager, &c.Popularity} {
		c.Convert()
	}

	return c, nil

}
859349
func (r *Reader) Read(p []byte) (int, error) {
	r.Lock()
	defer r.Unlock()
	return r.r.Read(p)
}
75894
func (c *Connector) read(
	ctx context.Context,
	ei *dosa.EntityInfo,
	keys map[string]dosa.FieldValue,
	source map[string]dosa.FieldValue,
	sourceErr error,
	methodName string,
) (values map[string]dosa.FieldValue, err error) {
	if dosa.ErrorIsNotFound(sourceErr) {
		return source, sourceErr
	}

	ckey := createCacheKey(ei, keys)
	value, err := c.getValueFromFallback(ctx, ei, ckey)
	c.logFallback(methodName, ei.Def.Name, err)
	if err != nil {
		return source, sourceErr
	}
	result := map[string]dosa.FieldValue{}
	err = c.encoder.Decode(value, &result)
	if err != nil {
		return source, sourceErr
	}
	return rawRowAsPointers(ei, result), err
}
271023
func (f *File) Read(ctx context.Context, req *fuse.ReadRequest,
	resp *fuse.ReadResponse) (err error) {
	off := req.Offset
	sz := cap(resp.Data)
	ctx = f.folder.fs.config.MaybeStartTrace(ctx, "File.Read",
		fmt.Sprintf("%s off=%d sz=%d", f.node.GetBasename(), off, sz))
	defer func() { f.folder.fs.config.MaybeFinishTrace(ctx, err) }()

	f.folder.fs.vlog.CLogf(ctx, libkb.VLog1, "File Read off=%d sz=%d", off, sz)
	defer func() { err = f.folder.processError(ctx, libkbfs.ReadMode, err) }()

	n, err := f.folder.fs.config.KBFSOps().Read(
		ctx, f.node, resp.Data[:sz], off)
	if err != nil {
		return err
	}
	resp.Data = resp.Data[:n]
	return nil
}
714307
func Read() (string, error) {
	keyPath, err := kiteKeyPath()
	if err != nil {
		return "", err
	}
	data, err := ioutil.ReadFile(keyPath)
	if err != nil {
		return "", err
	}
	return strings.TrimSpace(string(data)), nil
}
554162
func (r *UploadPackResponse) Read(p []byte) (int, error) {
	if r.r == nil {
		return 0, ErrUploadPackResponseNotDecoded
	}

	return r.r.Read(p)
}
872743
func (s *GlobConfig) Read(id string) error {
	key := globalConfigPath
	return s.StateDriver.ReadState(key, s, json.Unmarshal)
}
739337
func (c *CipherReader) Read(p []byte) (n int, err error) {
	n, err = c.r.Read(p)
	ws.Cipher(p[:n], c.mask, c.pos)
	c.pos += n
	return
}
152004
func (c *Conn) Read(p []byte) (int, error) {
	return c.r.Read(p)
}