Sha256: fe80cf0af85bd67e44eecdab91736c0691f56714b80043d9b63057a2a6fd7040

Contents?: true

Size: 1.29 KB

Versions: 71

Compression:

Stored size: 1.29 KB

Contents

#include <Gosu/IO.hpp>
#include <cassert>
#include <cstring>

void Gosu::Reader::read(void* dest, std::size_t length)
{
    res->read(pos, length, dest);
    seek(length);
}

void Gosu::Writer::write(const void* source, std::size_t length)
{
    // Try to resize the source if necessary.
    if (pos + length > res->size())
        res->resize(pos + length);

    res->write(pos, length, source);
    seek(length);
}

std::size_t Gosu::Buffer::size() const
{
    return buf.size();
}

void Gosu::Buffer::resize(std::size_t newSize)
{
    buf.resize(newSize);
}

void Gosu::Buffer::read(std::size_t offset, std::size_t length,
    void* destBuffer) const
{
    assert(offset + length <= size());
    if (length)
        std::memcpy(destBuffer, &buf[offset], length);
}

void Gosu::Buffer::write(std::size_t offset, std::size_t length,
    const void* sourceBuffer)
{
    assert(offset + length <= size());
    if (length)
        std::memcpy(&buf[offset], sourceBuffer, length);
}

void Gosu::loadFile(Buffer& buffer, const std::wstring& filename)
{
    File file(filename);
    buffer.resize(file.size());
    file.read(0, buffer.size(), buffer.data());
}

void Gosu::saveFile(const Buffer& buffer, const std::wstring& filename)
{
    File file(filename, fmReplace);
    file.write(0, buffer.size(), buffer.data());
}

Version data entries

71 entries across 71 versions & 1 rubygems

Version Path
gosu-0.10.9.pre1 src/IO.cpp
gosu-0.10.8 src/IO.cpp
gosu-0.10.7 src/IO.cpp
gosu-0.10.6 src/IO.cpp
gosu-0.10.5 src/IO.cpp
gosu-0.10.5.pre0 src/IO.cpp
gosu-0.10.5.pre1 src/IO.cpp
gosu-0.10.4 src/IO.cpp
gosu-0.10.3 src/IO.cpp
gosu-0.10.2 src/IO.cpp
gosu-0.10.2.pre1 src/IO.cpp
gosu-0.10.1.2 src/IO.cpp
gosu-0.10.1.1 src/IO.cpp
gosu-0.10.1 src/IO.cpp
gosu-0.10.0 src/IO.cpp
gosu-0.9.2 src/IO.cpp
gosu-0.9.2.pre1 src/IO.cpp
gosu-0.9.1 src/IO.cpp
gosu-0.9.0 src/IO.cpp
gosu-0.9.0.pre1 src/IO.cpp