Added File::Open(path, mode)

Former-commit-id: 7bd80f04e5f902e9752b1f5091ac55cdf2bc432a
This commit is contained in:
Lynix 2014-04-20 13:13:49 +02:00
parent e16e3658f1
commit fc970c503a
2 changed files with 12 additions and 2 deletions

View File

@ -78,6 +78,7 @@ class NAZARA_API NzFile : public NzHashable, public NzInputStream, NzNonCopyable
bool IsOpen() const; bool IsOpen() const;
bool Open(unsigned long openMode = Current); 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 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);

View File

@ -49,8 +49,7 @@ m_endianness(nzEndianness_Unknown),
m_impl(nullptr), m_impl(nullptr),
m_openMode(0) m_openMode(0)
{ {
SetFile(filePath); Open(filePath, openMode);
Open(openMode);
} }
NzFile::NzFile(NzFile&& file) noexcept : NzFile::NzFile(NzFile&& file) noexcept :
@ -313,6 +312,16 @@ bool NzFile::Open(unsigned long openMode)
return true; 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) bool NzFile::SetCursorPos(CursorPosition pos, nzInt64 offset)
{ {
NazaraLock(m_mutex) NazaraLock(m_mutex)