From fc970c503a4106e32ce003b7f0b94f304b7f35cf Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 20 Apr 2014 13:13:49 +0200 Subject: [PATCH] Added File::Open(path, mode) Former-commit-id: 7bd80f04e5f902e9752b1f5091ac55cdf2bc432a --- include/Nazara/Core/File.hpp | 1 + src/Nazara/Core/File.cpp | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/include/Nazara/Core/File.hpp b/include/Nazara/Core/File.hpp index 65c442b45..8eff60c73 100644 --- a/include/Nazara/Core/File.hpp +++ b/include/Nazara/Core/File.hpp @@ -78,6 +78,7 @@ class NAZARA_API NzFile : public NzHashable, public NzInputStream, NzNonCopyable bool IsOpen() const; bool Open(unsigned long openMode = Current); + bool Open(const NzString& filePath, 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); diff --git a/src/Nazara/Core/File.cpp b/src/Nazara/Core/File.cpp index db25a64bc..aa803a9fa 100644 --- a/src/Nazara/Core/File.cpp +++ b/src/Nazara/Core/File.cpp @@ -49,8 +49,7 @@ m_endianness(nzEndianness_Unknown), m_impl(nullptr), m_openMode(0) { - SetFile(filePath); - Open(openMode); + Open(filePath, openMode); } NzFile::NzFile(NzFile&& file) noexcept : @@ -313,6 +312,16 @@ bool NzFile::Open(unsigned long openMode) return true; } +bool NzFile::Open(const NzString& filePath, unsigned long openMode) +{ + NazaraLock(m_mutex) + + Close(); + + SetFile(filePath); + return Open(openMode); +} + bool NzFile::SetCursorPos(CursorPosition pos, nzInt64 offset) { NazaraLock(m_mutex)