Added NzInputStream
Added NzFile::Read(buffer, size) NzFile::Read(nullptr, size) now acts as a skip function (ex: SetCursorPos(GetCursorPos() + size)
This commit is contained in:
parent
182bd4cffe
commit
cef402c8a5
|
|
@ -71,6 +71,9 @@
|
||||||
#define NAZARA_THREADSAFETY_STRINGSTREAM 0 // NzStringStream
|
#define NAZARA_THREADSAFETY_STRINGSTREAM 0 // NzStringStream
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Optimise certaines parties du code avec les avancées venues de Windows Vista (Nécessite Vista ou supérieur et compilateur compatible)
|
||||||
|
#define NAZARA_CORE_WINDOWS_VISTA 0
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// Règle le temps entre le réveil du thread des timers et l'activation d'un timer (En millisecondes)
|
// Règle le temps entre le réveil du thread des timers et l'activation d'un timer (En millisecondes)
|
||||||
#define NAZARA_CORE_TIMER_WAKEUPTIME 10
|
#define NAZARA_CORE_TIMER_WAKEUPTIME 10
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
#define NAZARA_ERROR_HPP
|
#define NAZARA_ERROR_HPP
|
||||||
|
|
||||||
#include <Nazara/Prerequesites.hpp>
|
#include <Nazara/Prerequesites.hpp>
|
||||||
|
#include <Nazara/Core/Config.hpp>
|
||||||
#include <Nazara/Core/String.hpp>
|
#include <Nazara/Core/String.hpp>
|
||||||
|
|
||||||
#if NAZARA_CORE_ENABLE_ASSERTS || defined(NAZARA_DEBUG)
|
#if NAZARA_CORE_ENABLE_ASSERTS || defined(NAZARA_DEBUG)
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
#include <Nazara/Core/Endianness.hpp>
|
#include <Nazara/Core/Endianness.hpp>
|
||||||
#include <Nazara/Core/Hashable.hpp>
|
#include <Nazara/Core/Hashable.hpp>
|
||||||
#include <Nazara/Core/HashDigest.hpp>
|
#include <Nazara/Core/HashDigest.hpp>
|
||||||
|
#include <Nazara/Core/InputStream.hpp>
|
||||||
#include <Nazara/Core/String.hpp>
|
#include <Nazara/Core/String.hpp>
|
||||||
#include <Nazara/Utility/NonCopyable.hpp>
|
#include <Nazara/Utility/NonCopyable.hpp>
|
||||||
|
|
||||||
|
|
@ -20,7 +21,7 @@
|
||||||
|
|
||||||
class NzFileImpl;
|
class NzFileImpl;
|
||||||
|
|
||||||
class NAZARA_API NzFile : public NzHashable, NzNonCopyable
|
class NAZARA_API NzFile : public NzHashable, public NzInputStream, NzNonCopyable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum CursorPosition
|
enum CursorPosition
|
||||||
|
|
@ -74,6 +75,7 @@ class NAZARA_API NzFile : public NzHashable, NzNonCopyable
|
||||||
|
|
||||||
bool Open(unsigned long openMode = Current);
|
bool Open(unsigned long openMode = Current);
|
||||||
|
|
||||||
|
std::size_t Read(void* buffer, std::size_t size);
|
||||||
std::size_t Read(void* buffer, std::size_t typeSize, unsigned int count);
|
std::size_t Read(void* buffer, std::size_t typeSize, unsigned int count);
|
||||||
bool Rename(const NzString& newFilePath);
|
bool Rename(const NzString& newFilePath);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
// Copyright (C) 2012 Jérôme Leclercq
|
||||||
|
// This file is part of the "Nazara Engine".
|
||||||
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef NAZARA_INPUTSTREAM_HPP
|
||||||
|
#define NAZARA_INPUTSTREAM_HPP
|
||||||
|
|
||||||
|
#include <Nazara/Prerequesites.hpp>
|
||||||
|
|
||||||
|
class NzInputStream
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~NzInputStream();
|
||||||
|
|
||||||
|
virtual bool EndOfFile() const = 0;
|
||||||
|
virtual std::size_t Read(void* buffer, std::size_t size) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // NAZARA_INPUTSTREAM_HPP
|
||||||
|
|
@ -283,19 +283,19 @@ class NAZARA_API NzString : public NzHashable
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedString(unsigned int bufferSize, unsigned int stringSize, unsigned short referenceCount, char* str) :
|
SharedString(unsigned short referenceCount, unsigned int bufferSize, unsigned int stringSize, char* str) :
|
||||||
allocatedSize(bufferSize),
|
allocatedSize(bufferSize),
|
||||||
size(stringSize),
|
size(stringSize),
|
||||||
refCount(referenceCount),
|
string(str),
|
||||||
string(str)
|
refCount(referenceCount)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int allocatedSize;
|
unsigned int allocatedSize;
|
||||||
unsigned int size;
|
unsigned int size;
|
||||||
unsigned short refCount;
|
|
||||||
char* string;
|
char* string;
|
||||||
|
|
||||||
|
unsigned short refCount;
|
||||||
NazaraMutex(mutex)
|
NazaraMutex(mutex)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
#include <Nazara/Core/Directory.hpp>
|
#include <Nazara/Core/Directory.hpp>
|
||||||
|
#include <Nazara/Core/Config.hpp>
|
||||||
#include <Nazara/Core/Error.hpp>
|
#include <Nazara/Core/Error.hpp>
|
||||||
#include <Nazara/Core/File.hpp>
|
#include <Nazara/Core/File.hpp>
|
||||||
//#include <Nazara/ThreadLocalVar.h>
|
//#include <Nazara/ThreadLocalVar.h>
|
||||||
|
|
|
||||||
|
|
@ -270,7 +270,7 @@ bool NzFile::IsOpen() const
|
||||||
return m_impl != nullptr;
|
return m_impl != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t NzFile::Read(void* buffer, std::size_t typeSize, unsigned int count)
|
std::size_t NzFile::Read(void* buffer, std::size_t size)
|
||||||
{
|
{
|
||||||
NazaraLock(m_mutex)
|
NazaraLock(m_mutex)
|
||||||
|
|
||||||
|
|
@ -288,14 +288,28 @@ std::size_t NzFile::Read(void* buffer, std::size_t typeSize, unsigned int count)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!buffer || count == 0 || typeSize == 0)
|
if (size == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
std::size_t byteRead = m_impl->Read(buffer, typeSize*count);
|
if (buffer)
|
||||||
|
return m_impl->Read(buffer, size);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nzUInt64 currentPos = m_impl->GetCursorPos();
|
||||||
|
|
||||||
|
m_impl->SetCursorPos(NzFile::AtCurrent, size);
|
||||||
|
|
||||||
|
return m_impl->GetCursorPos()-currentPos;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::size_t NzFile::Read(void* buffer, std::size_t typeSize, unsigned int count)
|
||||||
|
{
|
||||||
|
std::size_t byteRead = Read(buffer, typeSize*count);
|
||||||
if (byteRead == 0)
|
if (byteRead == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (m_endianness != nzEndianness_Unknown && m_endianness != NzGetPlatformEndianness() && typeSize != 1)
|
if (buffer && m_endianness != nzEndianness_Unknown && m_endianness != NzGetPlatformEndianness() && typeSize != 1)
|
||||||
{
|
{
|
||||||
unsigned int typeCount = byteRead/typeSize;
|
unsigned int typeCount = byteRead/typeSize;
|
||||||
for (unsigned int i = 0; i < typeCount; ++i)
|
for (unsigned int i = 0; i < typeCount; ++i)
|
||||||
|
|
|
||||||
|
|
@ -761,15 +761,18 @@ void SHA256_End(SHA_CTX* context, nzUInt8* digest)
|
||||||
|
|
||||||
|
|
||||||
/*** SHA-224: *********************************************************/
|
/*** SHA-224: *********************************************************/
|
||||||
void SHA224_Init(SHA_CTX* context) {
|
void SHA224_Init(SHA_CTX* context)
|
||||||
|
{
|
||||||
SHA256_Internal_Init(context, sha224_initial_hash_value);
|
SHA256_Internal_Init(context, sha224_initial_hash_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHA224_Internal_Transform(SHA_CTX* context, const nzUInt32* data) {
|
void SHA224_Internal_Transform(SHA_CTX* context, const nzUInt32* data)
|
||||||
|
{
|
||||||
SHA256_Internal_Transform(context, data);
|
SHA256_Internal_Transform(context, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHA224_Update(SHA_CTX* context, const nzUInt8 *data, std::size_t len) {
|
void SHA224_Update(SHA_CTX* context, const nzUInt8 *data, std::size_t len)
|
||||||
|
{
|
||||||
SHA256_Update(context, data, len);
|
SHA256_Update(context, data, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -807,7 +810,8 @@ void SHA512_Internal_Init(SHA_CTX* context, const nzUInt64* ihv)
|
||||||
context->s512.bitcount[0] = context->s512.bitcount[1] = 0;
|
context->s512.bitcount[0] = context->s512.bitcount[1] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHA512_Init(SHA_CTX* context) {
|
void SHA512_Init(SHA_CTX* context)
|
||||||
|
{
|
||||||
SHA512_Internal_Init(context, sha512_initial_hash_value);
|
SHA512_Internal_Init(context, sha512_initial_hash_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,8 @@
|
||||||
#ifndef NAZARA_HASH_SHA2_INTERNAL_HPP
|
#ifndef NAZARA_HASH_SHA2_INTERNAL_HPP
|
||||||
#define NAZARA_HASH_SHA2_INTERNAL_HPP
|
#define NAZARA_HASH_SHA2_INTERNAL_HPP
|
||||||
|
|
||||||
|
#include <Nazara/Prerequesites.hpp>
|
||||||
|
|
||||||
/* Digest lengths for SHA-1/224/256/384/512 */
|
/* Digest lengths for SHA-1/224/256/384/512 */
|
||||||
#define SHA1_DIGEST_LENGTH 20
|
#define SHA1_DIGEST_LENGTH 20
|
||||||
#define SHA1_DIGEST_STRING_LENGTH (SHA1_DIGEST_LENGTH * 2 + 1)
|
#define SHA1_DIGEST_STRING_LENGTH (SHA1_DIGEST_LENGTH * 2 + 1)
|
||||||
|
|
@ -54,8 +56,6 @@
|
||||||
#define SHA512_DIGEST_LENGTH 64
|
#define SHA512_DIGEST_LENGTH 64
|
||||||
#define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1)
|
#define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1)
|
||||||
|
|
||||||
#include <Nazara/Prerequesites.hpp>
|
|
||||||
|
|
||||||
union SHA_CTX
|
union SHA_CTX
|
||||||
{
|
{
|
||||||
/* SHA-1 uses this part of the union: */
|
/* SHA-1 uses this part of the union: */
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
#include <Nazara/Core/HashDigest.hpp>
|
#include <Nazara/Core/HashDigest.hpp>
|
||||||
|
#include <Nazara/Core/Config.hpp>
|
||||||
#include <Nazara/Core/Error.hpp>
|
#include <Nazara/Core/Error.hpp>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
// Copyright (C) 2012 Jérôme Leclercq
|
||||||
|
// This file is part of the "Nazara Engine".
|
||||||
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
|
#include <Nazara/Core/InputStream.hpp>
|
||||||
|
#include <Nazara/Core/Debug.hpp>
|
||||||
|
|
||||||
|
NzInputStream::~NzInputStream() = default;
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
#include <Nazara/Core/Log.hpp>
|
#include <Nazara/Core/Log.hpp>
|
||||||
|
#include <Nazara/Core/Config.hpp>
|
||||||
#include <Nazara/Core/File.hpp>
|
#include <Nazara/Core/File.hpp>
|
||||||
#include <Nazara/Core/StringStream.hpp>
|
#include <Nazara/Core/StringStream.hpp>
|
||||||
#include <Nazara/Math/Basic.hpp>
|
#include <Nazara/Math/Basic.hpp>
|
||||||
|
|
|
||||||
|
|
@ -3269,7 +3269,7 @@ NzString NzString::Resized(int size, char character) const
|
||||||
|
|
||||||
str[newSize] = '\0';
|
str[newSize] = '\0';
|
||||||
|
|
||||||
return NzString(new SharedString(newSize, newSize, 1, str));
|
return NzString(new SharedString(1, newSize, newSize, str));
|
||||||
}
|
}
|
||||||
|
|
||||||
NzString& NzString::Reverse()
|
NzString& NzString::Reverse()
|
||||||
|
|
@ -3302,7 +3302,7 @@ NzString NzString::Reversed() const
|
||||||
|
|
||||||
str[m_sharedString->size] = '\0';
|
str[m_sharedString->size] = '\0';
|
||||||
|
|
||||||
return NzString(new SharedString(m_sharedString->size, m_sharedString->size, 1, str));
|
return NzString(new SharedString(1, m_sharedString->size, m_sharedString->size, str));
|
||||||
}
|
}
|
||||||
|
|
||||||
NzString NzString::Simplified(nzUInt32 flags) const
|
NzString NzString::Simplified(nzUInt32 flags) const
|
||||||
|
|
@ -3360,7 +3360,7 @@ NzString NzString::Simplified(nzUInt32 flags) const
|
||||||
|
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
|
|
||||||
return NzString(new SharedString(m_sharedString->size, p-str, 1, str));
|
return NzString(new SharedString(1, m_sharedString->size, p-str, str));
|
||||||
}
|
}
|
||||||
|
|
||||||
NzString& NzString::Simplify(nzUInt32 flags)
|
NzString& NzString::Simplify(nzUInt32 flags)
|
||||||
|
|
@ -3691,7 +3691,7 @@ NzString NzString::Substr(int startPos, int endPos) const
|
||||||
std::memcpy(str, &m_sharedString->string[start], size*sizeof(char));
|
std::memcpy(str, &m_sharedString->string[start], size*sizeof(char));
|
||||||
str[size] = '\0';
|
str[size] = '\0';
|
||||||
|
|
||||||
return NzString(new SharedString(size, size, 1, str));
|
return NzString(new SharedString(1, size, size, str));
|
||||||
}
|
}
|
||||||
|
|
||||||
NzString NzString::SubstrFrom(char character, int startPos, bool fromLast, bool include, nzUInt32 flags) const
|
NzString NzString::SubstrFrom(char character, int startPos, bool fromLast, bool include, nzUInt32 flags) const
|
||||||
|
|
@ -3890,7 +3890,7 @@ NzString NzString::ToLower(nzUInt32 flags) const
|
||||||
|
|
||||||
*s = '\0';
|
*s = '\0';
|
||||||
|
|
||||||
return NzString(new SharedString(m_sharedString->size, m_sharedString->size, 1, str));
|
return NzString(new SharedString(1, m_sharedString->size, m_sharedString->size, str));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3922,7 +3922,7 @@ NzString NzString::ToUpper(nzUInt32 flags) const
|
||||||
|
|
||||||
*s = '\0';
|
*s = '\0';
|
||||||
|
|
||||||
return NzString(new SharedString(m_sharedString->size, m_sharedString->size, 1, str));
|
return NzString(new SharedString(1, m_sharedString->size, m_sharedString->size, str));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4206,7 +4206,7 @@ NzString NzString::operator+(char character) const
|
||||||
str[m_sharedString->size] = character;
|
str[m_sharedString->size] = character;
|
||||||
str[totalSize] = '\0';
|
str[totalSize] = '\0';
|
||||||
|
|
||||||
return NzString(new SharedString(totalSize, totalSize, 1, str));
|
return NzString(new SharedString(1, totalSize, totalSize, str));
|
||||||
}
|
}
|
||||||
|
|
||||||
NzString NzString::operator+(const char* string) const
|
NzString NzString::operator+(const char* string) const
|
||||||
|
|
@ -4226,7 +4226,7 @@ NzString NzString::operator+(const char* string) const
|
||||||
std::memcpy(str, m_sharedString->string, m_sharedString->size*sizeof(char));
|
std::memcpy(str, m_sharedString->string, m_sharedString->size*sizeof(char));
|
||||||
std::strcpy(&str[m_sharedString->size], string);
|
std::strcpy(&str[m_sharedString->size], string);
|
||||||
|
|
||||||
return NzString(new SharedString(totalSize, totalSize, 1, str));
|
return NzString(new SharedString(1, totalSize, totalSize, str));
|
||||||
}
|
}
|
||||||
|
|
||||||
NzString NzString::operator+(const std::string& string) const
|
NzString NzString::operator+(const std::string& string) const
|
||||||
|
|
@ -4242,7 +4242,7 @@ NzString NzString::operator+(const std::string& string) const
|
||||||
std::memcpy(str, m_sharedString->string, m_sharedString->size*sizeof(char));
|
std::memcpy(str, m_sharedString->string, m_sharedString->size*sizeof(char));
|
||||||
std::strcpy(&str[m_sharedString->size], string.c_str());
|
std::strcpy(&str[m_sharedString->size], string.c_str());
|
||||||
|
|
||||||
return NzString(new SharedString(totalSize, totalSize, 1, str));
|
return NzString(new SharedString(1, totalSize, totalSize, str));
|
||||||
}
|
}
|
||||||
|
|
||||||
NzString NzString::operator+(const NzString& string) const
|
NzString NzString::operator+(const NzString& string) const
|
||||||
|
|
@ -4258,7 +4258,7 @@ NzString NzString::operator+(const NzString& string) const
|
||||||
std::memcpy(str, m_sharedString->string, m_sharedString->size*sizeof(char));
|
std::memcpy(str, m_sharedString->string, m_sharedString->size*sizeof(char));
|
||||||
std::strcpy(&str[m_sharedString->size], string.m_sharedString->string);
|
std::strcpy(&str[m_sharedString->size], string.m_sharedString->string);
|
||||||
|
|
||||||
return NzString(new SharedString(totalSize, totalSize, 1, str));
|
return NzString(new SharedString(1, totalSize, totalSize, str));
|
||||||
}
|
}
|
||||||
|
|
||||||
NzString& NzString::operator+=(char character)
|
NzString& NzString::operator+=(char character)
|
||||||
|
|
@ -4610,7 +4610,7 @@ NzString NzString::Boolean(bool boolean)
|
||||||
char* str = new char[size+1];
|
char* str = new char[size+1];
|
||||||
std::strcpy(str, (boolean) ? "true" : "false");
|
std::strcpy(str, (boolean) ? "true" : "false");
|
||||||
|
|
||||||
return NzString(new SharedString(size, size, 1, str));
|
return NzString(new SharedString(1, size, size, str));
|
||||||
}
|
}
|
||||||
|
|
||||||
int NzString::Compare(const NzString& first, const NzString& second)
|
int NzString::Compare(const NzString& first, const NzString& second)
|
||||||
|
|
@ -4707,7 +4707,7 @@ NzString NzString::Pointer(const void* ptr)
|
||||||
char* str = new char[size+1];
|
char* str = new char[size+1];
|
||||||
std::sprintf(str, "%p", ptr);
|
std::sprintf(str, "%p", ptr);
|
||||||
|
|
||||||
return NzString(new SharedString(size, size, 1, str));
|
return NzString(new SharedString(1, size, size, str));
|
||||||
}
|
}
|
||||||
|
|
||||||
NzString NzString::Unicode(char32_t character)
|
NzString NzString::Unicode(char32_t character)
|
||||||
|
|
@ -4729,7 +4729,7 @@ NzString NzString::Unicode(char32_t character)
|
||||||
utf8::append(character, str);
|
utf8::append(character, str);
|
||||||
str[count] = '\0';
|
str[count] = '\0';
|
||||||
|
|
||||||
return NzString(new SharedString(count, count, 1, str));
|
return NzString(new SharedString(1, count, count, str));
|
||||||
}
|
}
|
||||||
|
|
||||||
NzString NzString::Unicode(const char* u8String)
|
NzString NzString::Unicode(const char* u8String)
|
||||||
|
|
@ -4754,7 +4754,7 @@ NzString NzString::Unicode(const char16_t* u16String)
|
||||||
char* r = utf8::utf16to8(u16String, ptr, str);
|
char* r = utf8::utf16to8(u16String, ptr, str);
|
||||||
*r = '\0';
|
*r = '\0';
|
||||||
|
|
||||||
return NzString(new SharedString(count, r-str, 1, str));
|
return NzString(new SharedString(1, count, r-str, str));
|
||||||
}
|
}
|
||||||
|
|
||||||
NzString NzString::Unicode(const char32_t* u32String)
|
NzString NzString::Unicode(const char32_t* u32String)
|
||||||
|
|
@ -4782,7 +4782,7 @@ NzString NzString::Unicode(const char32_t* u32String)
|
||||||
char* r = utf8::utf32to8(u32String, ptr, str);
|
char* r = utf8::utf32to8(u32String, ptr, str);
|
||||||
*r = '\0';
|
*r = '\0';
|
||||||
|
|
||||||
return NzString(new SharedString(count, count, 1, str));
|
return NzString(new SharedString(1, count, count, str));
|
||||||
}
|
}
|
||||||
|
|
||||||
NzString NzString::Unicode(const wchar_t* wString)
|
NzString NzString::Unicode(const wchar_t* wString)
|
||||||
|
|
@ -4810,7 +4810,7 @@ NzString NzString::Unicode(const wchar_t* wString)
|
||||||
char* r = utf8::utf32to8(wString, ptr, str);
|
char* r = utf8::utf32to8(wString, ptr, str);
|
||||||
*r = '\0';
|
*r = '\0';
|
||||||
|
|
||||||
return NzString(new SharedString(count, count, 1, str));
|
return NzString(new SharedString(1, count, count, str));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::istream& operator>>(std::istream& is, NzString& str)
|
std::istream& operator>>(std::istream& is, NzString& str)
|
||||||
|
|
@ -4859,7 +4859,7 @@ NzString operator+(char character, const NzString& string)
|
||||||
str[0] = character;
|
str[0] = character;
|
||||||
std::strcpy(str, string.m_sharedString->string);
|
std::strcpy(str, string.m_sharedString->string);
|
||||||
|
|
||||||
return NzString(new NzString::SharedString(totalSize, totalSize, 1, str));
|
return NzString(new NzString::SharedString(1, totalSize, totalSize, str));
|
||||||
}
|
}
|
||||||
|
|
||||||
NzString operator+(const char* string, const NzString& nstring)
|
NzString operator+(const char* string, const NzString& nstring)
|
||||||
|
|
@ -4876,7 +4876,7 @@ NzString operator+(const char* string, const NzString& nstring)
|
||||||
std::memcpy(str, string, size*sizeof(char));
|
std::memcpy(str, string, size*sizeof(char));
|
||||||
std::strcpy(&str[size], nstring.m_sharedString->string);
|
std::strcpy(&str[size], nstring.m_sharedString->string);
|
||||||
|
|
||||||
return NzString(new NzString::SharedString(totalSize, totalSize, 1, str));
|
return NzString(new NzString::SharedString(1, totalSize, totalSize, str));
|
||||||
}
|
}
|
||||||
|
|
||||||
NzString operator+(const std::string& string, const NzString& nstring)
|
NzString operator+(const std::string& string, const NzString& nstring)
|
||||||
|
|
@ -4892,7 +4892,7 @@ NzString operator+(const std::string& string, const NzString& nstring)
|
||||||
std::memcpy(str, string.c_str(), string.size()*sizeof(char));
|
std::memcpy(str, string.c_str(), string.size()*sizeof(char));
|
||||||
std::strcpy(&str[string.size()], nstring.m_sharedString->string);
|
std::strcpy(&str[string.size()], nstring.m_sharedString->string);
|
||||||
|
|
||||||
return NzString(new NzString::SharedString(totalSize, totalSize, 1, str));
|
return NzString(new NzString::SharedString(1, totalSize, totalSize, str));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(const NzString& first, const NzString& second)
|
bool operator==(const NzString& first, const NzString& second)
|
||||||
|
|
@ -5040,7 +5040,7 @@ void NzString::EnsureOwnership()
|
||||||
char* string = new char[m_sharedString->allocatedSize+1];
|
char* string = new char[m_sharedString->allocatedSize+1];
|
||||||
std::strcpy(string, m_sharedString->string);
|
std::strcpy(string, m_sharedString->string);
|
||||||
|
|
||||||
m_sharedString = new SharedString(m_sharedString->allocatedSize, m_sharedString->size, 1, string);
|
m_sharedString = new SharedString(1, m_sharedString->allocatedSize, m_sharedString->size, string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
// Inspiré du code de la SFML par Laurent Gomila
|
// Inspiré du code de la SFML par Laurent Gomila
|
||||||
|
|
||||||
#include <Nazara/Core/Thread.hpp>
|
#include <Nazara/Core/Thread.hpp>
|
||||||
|
#include <Nazara/Core/Config.hpp>
|
||||||
#include <Nazara/Core/Error.hpp>
|
#include <Nazara/Core/Error.hpp>
|
||||||
|
|
||||||
#if defined(NAZARA_PLATFORM_WINDOWS)
|
#if defined(NAZARA_PLATFORM_WINDOWS)
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
#include <Nazara/Core/Unicode.hpp>
|
#include <Nazara/Core/Unicode.hpp>
|
||||||
|
#include <Nazara/Core/Config.hpp>
|
||||||
#include <Nazara/Core/Debug.hpp>
|
#include <Nazara/Core/Debug.hpp>
|
||||||
|
|
||||||
namespace NzUnicode
|
namespace NzUnicode
|
||||||
|
|
|
||||||
|
|
@ -151,19 +151,15 @@ bool NzFileImpl::Copy(const NzString& sourcePath, const NzString& targetPath)
|
||||||
{
|
{
|
||||||
wchar_t* path = sourcePath.GetWideBuffer();
|
wchar_t* path = sourcePath.GetWideBuffer();
|
||||||
wchar_t* newPath = targetPath.GetWideBuffer();
|
wchar_t* newPath = targetPath.GetWideBuffer();
|
||||||
|
bool success = CopyFileW(path, newPath, false);
|
||||||
|
delete[] path;
|
||||||
|
delete[] newPath;
|
||||||
|
|
||||||
if (CopyFileW(path, newPath, false))
|
if (success)
|
||||||
{
|
|
||||||
delete[] path;
|
|
||||||
delete[] newPath;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NazaraError("Unable to copy file: " + NzGetLastSystemError());
|
NazaraError("Unable to copy file: " + NzGetLastSystemError());
|
||||||
delete[] path;
|
|
||||||
delete[] newPath;
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -172,17 +168,14 @@ bool NzFileImpl::Copy(const NzString& sourcePath, const NzString& targetPath)
|
||||||
bool NzFileImpl::Delete(const NzString& filePath)
|
bool NzFileImpl::Delete(const NzString& filePath)
|
||||||
{
|
{
|
||||||
wchar_t* path = filePath.GetWideBuffer();
|
wchar_t* path = filePath.GetWideBuffer();
|
||||||
|
bool success = DeleteFileW(path);
|
||||||
|
delete[] path;
|
||||||
|
|
||||||
if (DeleteFileW(path))
|
if (success)
|
||||||
{
|
|
||||||
delete[] path;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NazaraError("Unable to delete file (" + filePath + "): " + NzGetLastSystemError());
|
NazaraError("Unable to delete file (" + filePath + "): " + NzGetLastSystemError());
|
||||||
delete[] path;
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
#include <Nazara/Core/Win32/SemaphoreImpl.hpp>
|
#include <Nazara/Core/Win32/SemaphoreImpl.hpp>
|
||||||
|
#include <Nazara/Core/Config.hpp>
|
||||||
#include <Nazara/Core/Error.hpp>
|
#include <Nazara/Core/Error.hpp>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <Nazara/Core/Debug.hpp>
|
#include <Nazara/Core/Debug.hpp>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue