Returns a mapped buffer of the smooshed file with the given name. Buffer's contents from 0 to capacity() are the
whole mapped file contents, limit() is equal to capacity().
777463
public ByteBuffer mapFile(String name) throws IOException
  {
    final Metadata metadata = internalFiles.get(name);
    if (metadata == null) {
      return null;
    }

    final int fileNum = metadata.getFileNum();
    while (buffersList.size() <= fileNum) {
      buffersList.add(null);
    }

    MappedByteBuffer mappedBuffer = buffersList.get(fileNum);
    if (mappedBuffer == null) {
      mappedBuffer = Files.map(outFiles.get(fileNum));
      buffersList.set(fileNum, mappedBuffer);
    }

    ByteBuffer retVal = mappedBuffer.duplicate();
    retVal.position(metadata.getStartOffset()).limit(metadata.getEndOffset());
    return retVal.slice();
  }
1110011
def load(cls, filename, gzipped, byteorder='big'):
        
        open_file = gzip.open if gzipped else open
        with open_file(filename, 'rb') as buff:
            return cls.from_buffer(buff, byteorder)
278739
def file(name)
      File.open(name, "rb") {|f|
        buf = ""
        while f.read(16384, buf)
          update buf
        end
      }
      self
    end
440674
def dl_full_file(url, save_file_name):
    
    response = requests.get(url)
    with open(save_file_name, 'wb') as writefile:
        writefile.write(response.content)

    return
633374
public ByteBuffer[] split(ByteBuffer name)
    {
        List<ByteBuffer> l = new ArrayList<ByteBuffer>();
        ByteBuffer bb = name.duplicate();
        readIsStatic(bb);
        int i = 0;
        while (bb.remaining() > 0)
        {
            getComparator(i++, bb);
            l.add(ByteBufferUtil.readBytesWithShortLength(bb));
            bb.get(); // skip end-of-component
        }
        return l.toArray(new ByteBuffer[l.size()]);
    }
255738
def file
      content64 = get_if_handleable(raw[:contents])
      {
        :content => content64 ? Base64.decode64(content64) : nil,
        :size    => raw[:file_size].to_i,
        :name    => get_if_handleable(raw[:filename]),
        :md5     => get_if_handleable(raw[:md5_digest])
      }.reject { |k, v| v.nil? }
    end
470841
@Override
    public ByteBuffer getBuffer()
    {
        //  If we are expected to read large message, we'll opt for zero-
        //  copy, i.e. we'll ask caller to fill the data directly to the
        //  message. Note that subsequent read(s) are non-blocking, thus
        //  each single read reads at most SO_RCVBUF bytes at once not
        //  depending on how large is the chunk returned from here.
        //  As a consequence, large messages being received won't block
        //  other engines running in the same I/O thread for excessive
        //  amounts of time.
        if (toRead >= bufsize) {
            zeroCopy = true;
            return readPos.duplicate();
        }
        else {
            zeroCopy = false;
            buf.clear();
            return buf;
        }
    }
968149
private InputStream getSourceAsInputStream() throws IOException {
	if (!mapping.hasArchive()) return IOUtil.toBufferedInputStream(getPhyscalFile().getInputStream());
	else if (isLoad(LOAD_PHYSICAL)) return IOUtil.toBufferedInputStream(getPhyscalFile().getInputStream());
	else if (isLoad(LOAD_ARCHIVE)) {
	    StringBuffer name = new StringBuffer(_getPackageName().replace('.', '/'));
	    if (name.length() > 0) name.append("/");
	    name.append(getFileName());

	    return mapping.getArchiveResourceAsStream(name.toString());
	}
	else {
	    return null;
	}
    }
420465
def load_chunk(filename, bounds, encoding='utf8', slow=False):
    
    if slow:
        return _load_chunk_slow(filename, bounds, encoding)

    with open(filename, 'rb') as f:
        f.seek(bounds.byte_start)
        size = bounds.byte_end - bounds.byte_start
        return f.read(size).decode(encoding)
378810
public String map(String name) {
		String mapped = super.get(name);
		if (mapped == null) {
			mapped = String.format("%s%03d", BASENAME, count.incrementAndGet());
			super.put(name, mapped);
		}
		return mapped;
	}
837810
public long sizeInBytes()
    {
        long n = 0;
        for (CacheBucket bucket : cache.asMap().values())
            for (RandomAccessReader reader : bucket.queue)
                n += reader.getTotalBufferSize();
        return n;
    }
1164041
function getBufferPadded(buffer) {
    const boundary = 4;
    const byteLength = buffer.length;
    const remainder = byteLength % boundary;
    if (remainder === 0) {
        return buffer;
    }
    const padding = (remainder === 0) ? 0 : boundary - remainder;
    const emptyBuffer = Buffer.alloc(padding);
    return Buffer.concat([buffer, emptyBuffer]);
}
761296
def get_buffer(self):
        """"""
        buffer_size = self.reply.size()
        data = self.reply.read(buffer_size)
        self.downloaded_file_buffer.append(data)
883232
def __fill_buffer(self, size=0):
    
    read_size = min(max(size, self.__buffer_size), MAX_BLOB_FETCH_SIZE)

    self.__buffer = fetch_data(self.__blob_key, self.__position,
                               self.__position + read_size - 1)
    self.__buffer_position = 0
    self.__eof = len(self.__buffer) < read_size
1150932
def get_starting_chunk(filename, length=1024):
    
    # Ensure we open the file in binary mode
    with open(filename, 'rb') as f:
        chunk = f.read(length)
        return chunk
762954
function getFilesizeInBytes(fileName) {
    try {
        var stats = fs.statSync(fileName);
        return stats.size || 0;
    } catch (ex) {
        console.log(ex);
        return 0;
    }
}
812473
def namedbuffer(buffer_name, fields_spec):  # noqa (ignore ciclomatic complexity)
    
    # pylint: disable=protected-access,unused-argument

    if not len(buffer_name):
        raise ValueError('buffer_name is empty')

    if not len(fields_spec):
        raise ValueError('fields_spec is empty')

    fields = [
        field
        for field in fields_spec
        if not isinstance(field, Pad)
    ]

    if any(field.size_bytes < 0 for field in fields):
        raise ValueError('negative size_bytes')

    if any(len(field.name) < 0 for field in fields):
        raise ValueError('field missing name')

    names_fields = {
        field.name: field
        for field in fields
    }

    if 'data' in names_fields:
        raise ValueError('data field shadowing underlying buffer')

    if any(count > 1 for count in Counter(field.name for field in fields).values()):
        raise ValueError('repeated field name')

    # big endian format
    fields_format = '>' + ''.join(field.format_string for field in fields_spec)
    size = sum(field.size_bytes for field in fields_spec)
    names_slices = compute_slices(fields_spec)
    sorted_names = sorted(names_fields.keys())

    @staticmethod
    def get_bytes_from(buffer_, name):
        slice_ = names_slices[name]
        return buffer_[slice_]

    def __init__(self, data):
        if len(data) < size:
            raise InvalidProtocolMessage(
                'data buffer has less than the expected size {}'.format(size),
            )

        object.__setattr__(self, 'data', data)

    # Intentionally exposing only the attributes from the spec, since the idea
    # is for the instance to expose the underlying buffer as attributes
    def __getattribute__(self, name):
        if name in names_slices:
            slice_ = names_slices[name]
            field = names_fields[name]

            data = object.__getattribute__(self, 'data')
            value = data[slice_]

            if field.encoder:
                value = field.encoder.decode(value)

            return value

        if name == 'data':
            return object.__getattribute__(self, 'data')

        raise AttributeError

    def __setattr__(self, name, value):
        if name in names_slices:
            slice_ = names_slices[name]
            field = names_fields[name]

            if field.encoder:
                field.encoder.validate(value)
                value = field.encoder.encode(value, field.size_bytes)

            length = len(value)
            if length > field.size_bytes:
                msg = 'value with length {length} for {attr} is too big'.format(
                    length=length,
                    attr=name,
                )
                raise ValueError(msg)
            elif length < field.size_bytes:
                pad_size = field.size_bytes - length
                pad_value = b'\x00' * pad_size
                value = pad_value + value

            data = object.__getattribute__(self, 'data')
            if isinstance(value, str):
                value = value.encode()
            data[slice_] = value
        else:
            super(self.__class__, self).__setattr__(name, value)

    def __repr__(self):
        return '<{} [...]>'.format(buffer_name)

    def __len__(self):
        return size

    def __dir__(self):
        return sorted_names

    attributes = {
        '__init__': __init__,
        '__slots__': ('data',),
        '__getattribute__': __getattribute__,
        '__setattr__': __setattr__,
        '__repr__': __repr__,
        '__len__': __len__,
        '__dir__': __dir__,

        # These are class attributes hidden from instance, i.e. must be
        # accessed through the class instance.
        'fields_spec': fields_spec,
        'format': fields_format,
        'size': size,
        'get_bytes_from': get_bytes_from,
    }

    return type(buffer_name, (), attributes)