mirror of
https://github.com/NoelFB/blah.git
synced 2025-12-14 13:17:07 +08:00
replaced log.h with common.h, added easier shorthand for int types
This commit is contained in:
@ -42,7 +42,7 @@ BufferStream::~BufferStream()
|
||||
delete[] m_buffer;
|
||||
}
|
||||
|
||||
int64_t BufferStream::read_into(void* ptr, int64_t len)
|
||||
i64 BufferStream::read_into(void* ptr, i64 len)
|
||||
{
|
||||
if (m_buffer == nullptr || ptr == nullptr)
|
||||
return 0;
|
||||
@ -58,7 +58,7 @@ int64_t BufferStream::read_into(void* ptr, int64_t len)
|
||||
return len;
|
||||
}
|
||||
|
||||
int64_t BufferStream::write_from(const void* ptr, int64_t len)
|
||||
i64 BufferStream::write_from(const void* ptr, i64 len)
|
||||
{
|
||||
if (len < 0)
|
||||
return 0;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#include <blah/streams/filestream.h>
|
||||
#include <blah/core/log.h>
|
||||
#include <blah/core/common.h>
|
||||
#include "../internal/platform_backend.h"
|
||||
#include <string.h>
|
||||
|
||||
@ -39,7 +39,7 @@ FileStream::~FileStream()
|
||||
PlatformBackend::file_close(m_handle);
|
||||
}
|
||||
|
||||
int64_t FileStream::length() const
|
||||
i64 FileStream::length() const
|
||||
{
|
||||
if (m_handle == nullptr)
|
||||
return 0;
|
||||
@ -47,7 +47,7 @@ int64_t FileStream::length() const
|
||||
return PlatformBackend::file_length(m_handle);
|
||||
}
|
||||
|
||||
int64_t FileStream::position() const
|
||||
i64 FileStream::position() const
|
||||
{
|
||||
if (m_handle == nullptr)
|
||||
return 0;
|
||||
@ -55,7 +55,7 @@ int64_t FileStream::position() const
|
||||
return PlatformBackend::file_position(m_handle);
|
||||
}
|
||||
|
||||
int64_t FileStream::seek(int64_t seek_to)
|
||||
i64 FileStream::seek(i64 seek_to)
|
||||
{
|
||||
if (m_handle == nullptr)
|
||||
return 0;
|
||||
@ -63,7 +63,7 @@ int64_t FileStream::seek(int64_t seek_to)
|
||||
return PlatformBackend::file_seek(m_handle, seek_to);
|
||||
}
|
||||
|
||||
int64_t FileStream::read_into(void* ptr, int64_t length)
|
||||
i64 FileStream::read_into(void* ptr, i64 length)
|
||||
{
|
||||
if (m_handle == nullptr)
|
||||
{
|
||||
@ -74,7 +74,7 @@ int64_t FileStream::read_into(void* ptr, int64_t length)
|
||||
return PlatformBackend::file_read(m_handle, ptr, length);
|
||||
}
|
||||
|
||||
int64_t FileStream::write_from(const void* ptr, int64_t length)
|
||||
i64 FileStream::write_from(const void* ptr, i64 length)
|
||||
{
|
||||
if (length <= 0)
|
||||
return 0;
|
||||
|
||||
@ -6,7 +6,7 @@ using namespace Blah;
|
||||
MemoryStream::MemoryStream()
|
||||
: m_data(nullptr), m_length(0), m_position(0) {}
|
||||
|
||||
MemoryStream::MemoryStream(char* data, int64_t length)
|
||||
MemoryStream::MemoryStream(char* data, i64 length)
|
||||
: m_data(data), m_length(length), m_position(0) {}
|
||||
|
||||
MemoryStream::MemoryStream(MemoryStream&& src) noexcept
|
||||
@ -28,7 +28,7 @@ MemoryStream& MemoryStream::operator=(MemoryStream&& src) noexcept
|
||||
return *this;
|
||||
}
|
||||
|
||||
int64_t MemoryStream::read_into(void* ptr, int64_t len)
|
||||
i64 MemoryStream::read_into(void* ptr, i64 len)
|
||||
{
|
||||
if (len < 0 || ptr == nullptr)
|
||||
return 0;
|
||||
@ -41,7 +41,7 @@ int64_t MemoryStream::read_into(void* ptr, int64_t len)
|
||||
return len;
|
||||
}
|
||||
|
||||
int64_t MemoryStream::write_from(const void* ptr, int64_t len)
|
||||
i64 MemoryStream::write_from(const void* ptr, i64 len)
|
||||
{
|
||||
if (len < 0 || ptr == nullptr)
|
||||
return 0;
|
||||
|
||||
@ -4,10 +4,10 @@
|
||||
|
||||
using namespace Blah;
|
||||
|
||||
int64_t Stream::pipe(Stream& stream, int64_t length)
|
||||
i64 Stream::pipe(Stream& stream, i64 length)
|
||||
{
|
||||
const int BUFFER_LENGTH = 4096;
|
||||
int64_t result = 0;
|
||||
i64 result = 0;
|
||||
|
||||
char buffer[BUFFER_LENGTH];
|
||||
while (length > 0)
|
||||
@ -59,12 +59,12 @@ String Stream::read_line()
|
||||
return result;
|
||||
}
|
||||
|
||||
int64_t Stream::write(const void* buffer, int64_t length)
|
||||
i64 Stream::write(const void* buffer, i64 length)
|
||||
{
|
||||
return write_from(buffer, length);
|
||||
}
|
||||
|
||||
int64_t Stream::write(const String& string)
|
||||
i64 Stream::write(const String& string)
|
||||
{
|
||||
return write_from(string.begin(), string.length());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user