// GetEncodedSize implements the BlockServer interface for
// BlockServerDisk.
2967
func (b *BlockServerDisk) GetEncodedSize(
	ctx context.Context, tlfID tlf.ID, id kbfsblock.ID,
	context kbfsblock.Context) (
	size uint32, status keybase1.BlockStatus, err error) {
	if err := checkContext(ctx); err != nil {
		return 0, 0, err
	}

	defer func() {
		err = translateToBlockServerError(err)
	}()
	b.log.CDebugf(ctx,
		"BlockServerDisk.GetEncodedSize id=%s tlfID=%s context=%s",
		id, tlfID, context)
	tlfStorage, err := b.getStorage(tlfID)
	if err != nil {
		return 0, 0, err
	}

	tlfStorage.lock.RLock()
	defer tlfStorage.lock.RUnlock()
	if tlfStorage.store == nil {
		return 0, 0, errBlockServerDiskShutdown
	}

	hasContext, refStatus, err := tlfStorage.store.hasContext(ctx, id, context)
	if err != nil {
		return 0, 0, err
	}
	if !hasContext {
		return 0, 0, blockNonExistentError{id}
	}

	size64, err := tlfStorage.store.getDataSize(ctx, id)
	if err != nil {
		return 0, 0, err
	}
	return uint32(size64), refStatus.toBlockStatus(), nil
}
340165
func GetSize() (ws Size, err error) {
	_, _, ec := syscall.Syscall(syscall.SYS_IOCTL,
		uintptr(syscall.Stdout),
		uintptr(TIOCGWINSZ),
		uintptr(unsafe.Pointer(&ws)))

	err = getError(ec)

	if TIOCGWINSZ == 0 && err != nil {
		ws = Size{80, 25, 0, 0}
	}
	return ws, err
}
737498
func getSizeOfPayloadSizeField(payload []byte) int {
	s := 1
	for i := len(payload); i >= 256; i /= 256 {
		s++
	}
	return s
}
868949
func (cb *CommonBlock) GetEncodedSize() uint32 {
	cb.cacheMtx.RLock()
	defer cb.cacheMtx.RUnlock()
	return cb.cachedEncodedSize
}
692469
func (r *RepositoryContent) GetSize() int {
	if r == nil || r.Size == nil {
		return 0
	}
	return *r.Size
}
1301913
func (image *Image) GetSize() (size uint64, err error) {
	if image.image == nil {
		return 0, RbdErrorImageNotOpen
	}

	if ret := C.rbd_get_size(image.image, (*C.uint64_t)(&size)); ret < 0 {
		return 0, RBDError(ret)
	}

	return size, nil
}
137330
func getBucketSize(request *restful.Request) (time.Duration, error) {
	rawSize := request.QueryParameter("bucket")
	if rawSize == "" {
		return 0, nil
	}

	if len(rawSize) < 2 {
		return 0, fmt.Errorf("unable to parse bucket size: %q is too short to be a duration", rawSize)
	}
	var multiplier time.Duration
	var num string

	switch rawSize[len(rawSize)-1] {
	case 's':
		// could be s or ms
		if len(rawSize) < 3 || rawSize[len(rawSize)-2] != 'm' {
			multiplier = time.Second
			num = rawSize[:len(rawSize)-1]
		} else {
			multiplier = time.Millisecond
			num = rawSize[:len(rawSize)-2]
		}
	case 'h':
		multiplier = time.Hour
		num = rawSize[:len(rawSize)-1]
	case 'd':
		multiplier = 24 * time.Hour
		num = rawSize[:len(rawSize)-1]
	case 'm':
		multiplier = time.Minute
		num = rawSize[:len(rawSize)-1]
	default:
		return 0, fmt.Errorf("unable to parse bucket size: %q has no known duration suffix", rawSize)
	}

	parsedNum, err := strconv.ParseUint(num, 10, 64)
	if err != nil {
		return 0, err
	}

	return time.Duration(parsedNum) * multiplier, nil
}
1231044
func (d *Failstore) GetSize(k ds.Key) (int, error) {
	err := d.errfunc("getsize")
	if err != nil {
		return -1, err
	}

	return d.child.GetSize(k)
}
885317
func (o *ObjectStorage) EncodedObjectSize(h plumbing.Hash) (int64, error) {
	sz, err := o.EncodedObjectStorer.EncodedObjectSize(h)
	if err == plumbing.ErrObjectNotFound {
		return o.temporal.EncodedObjectSize(h)
	}

	return sz, err
}
1023363
func GetFileSize(path string) (int64, error) {
	fi, err := os.Lstat(path)
	if err != nil {
		return 0, err
	}
	return fi.Size(), nil
}
1100536
func (r *Repository) GetSize() int {
	if r == nil || r.Size == nil {
		return 0
	}
	return *r.Size
}
572606
func (d *MutexDatastore) GetSize(key ds.Key) (size int, err error) {
	d.RLock()
	defer d.RUnlock()
	return d.child.GetSize(key)
}
571241
func (p *PushEvent) GetSize() int {
	if p == nil || p.Size == nil {
		return 0
	}
	return *p.Size
}
1022715
func Getsize(t *os.File) (rows, cols int, err error) {
	ws, err := GetsizeFull(t)
	return int(ws.Rows), int(ws.Cols), err
}
1155356
func (cfp *FsPool) GetSize(fileIndex int64) int64 {
	return cfp.container.Files[fileIndex].Size
}
781601
func (b *BlockServerRemote) GetEncodedSize(
	ctx context.Context, tlfID tlf.ID, id kbfsblock.ID,
	context kbfsblock.Context) (
	size uint32, status keybase1.BlockStatus, err error) {
	ctx = rpc.WithFireNow(ctx)
	b.log.LazyTrace(ctx, "BServer: GetEncodedSize %s", id)
	defer func() {
		b.log.LazyTrace(
			ctx, "BServer: GetEncodedSize %s done (err=%v)", id, err)
		if err != nil {
			b.deferLog.CWarningf(
				ctx, "GetEncodedSize id=%s tlf=%s context=%s err=%v",
				id, tlfID, context, err)
		} else {
			b.deferLog.CDebugf(
				ctx, "GetEncodedSize id=%s tlf=%s context=%s sz=%d status=%s",
				id, tlfID, context, size, status)
		}
	}()

	arg := kbfsblock.MakeGetBlockArg(tlfID, id, context)
	arg.SizeOnly = true
	res, err := b.getConn.getClient().GetBlock(ctx, arg)
	if err != nil {
		return 0, 0, nil
	}
	return uint32(res.Size), res.Status, nil
}
53285
func (b *BlockServerMemory) GetEncodedSize(
	ctx context.Context, tlfID tlf.ID, id kbfsblock.ID,
	context kbfsblock.Context) (
	size uint32, status keybase1.BlockStatus, err error) {
	if err := checkContext(ctx); err != nil {
		return 0, 0, err
	}

	defer func() {
		err = translateToBlockServerError(err)
	}()
	b.log.CDebugf(ctx,
		"BlockServerMemory.GetEncodedSize id=%s tlfID=%s context=%s",
		id, tlfID, context)
	b.lock.RLock()
	defer b.lock.RUnlock()

	if b.m == nil {
		return 0, 0, errBlockServerMemoryShutdown
	}

	entry, ok := b.m[id]
	if !ok {
		return 0, 0, kbfsblock.ServerErrorBlockNonExistent{
			Msg: fmt.Sprintf("Block ID %s does not exist.", id)}
	}

	if entry.tlfID != tlfID {
		return 0, 0, fmt.Errorf("TLF ID mismatch: expected %s, got %s",
			entry.tlfID, tlfID)
	}

	exists, refStatus, err := entry.refs.checkExists(context)
	if err != nil {
		return 0, 0, err
	}
	if !exists {
		return 0, 0, blockNonExistentError{id}
	}

	return uint32(len(entry.blockData)), refStatus.toBlockStatus(), nil
}