Revert
Former-commit-id: cb73baf4bb2a95b65e8439ee552f7ad85ede1008
This commit is contained in:
parent
b29d1ffcd8
commit
4bbb02eadc
|
|
@ -85,10 +85,10 @@ void NzFile::Close()
|
||||||
|
|
||||||
bool NzFile::Delete()
|
bool NzFile::Delete()
|
||||||
{
|
{
|
||||||
Close();
|
|
||||||
|
|
||||||
NazaraLock(m_mutex)
|
NazaraLock(m_mutex)
|
||||||
|
|
||||||
|
Close();
|
||||||
|
|
||||||
return Delete(m_filePath);
|
return Delete(m_filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -266,12 +266,11 @@ std::size_t NzFile::Read(void* buffer, std::size_t typeSize, unsigned int count)
|
||||||
|
|
||||||
bool NzFile::Rename(const NzString& newFilePath)
|
bool NzFile::Rename(const NzString& newFilePath)
|
||||||
{
|
{
|
||||||
bool opened = IsOpen();
|
|
||||||
|
|
||||||
Close();
|
|
||||||
|
|
||||||
NazaraLock(m_mutex)
|
NazaraLock(m_mutex)
|
||||||
|
|
||||||
|
bool opened = IsOpen();
|
||||||
|
Close();
|
||||||
|
|
||||||
bool success = Rename(m_filePath, newFilePath);
|
bool success = Rename(m_filePath, newFilePath);
|
||||||
if (success)
|
if (success)
|
||||||
m_filePath = NormalizePath(newFilePath);
|
m_filePath = NormalizePath(newFilePath);
|
||||||
|
|
@ -284,10 +283,10 @@ bool NzFile::Rename(const NzString& newFilePath)
|
||||||
|
|
||||||
bool NzFile::Open(unsigned long openMode)
|
bool NzFile::Open(unsigned long openMode)
|
||||||
{
|
{
|
||||||
Close();
|
|
||||||
|
|
||||||
NazaraLock(m_mutex)
|
NazaraLock(m_mutex)
|
||||||
|
|
||||||
|
Close();
|
||||||
|
|
||||||
if (m_filePath.IsEmpty())
|
if (m_filePath.IsEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
@ -315,6 +314,8 @@ bool NzFile::Open(unsigned long openMode)
|
||||||
|
|
||||||
bool NzFile::Open(const NzString& filePath, unsigned long openMode)
|
bool NzFile::Open(const NzString& filePath, unsigned long openMode)
|
||||||
{
|
{
|
||||||
|
NazaraLock(m_mutex)
|
||||||
|
|
||||||
Close();
|
Close();
|
||||||
|
|
||||||
SetFile(filePath);
|
SetFile(filePath);
|
||||||
|
|
@ -359,11 +360,11 @@ void NzFile::SetEndianness(nzEndianness endianness)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NzFile::SetFile(const NzString& filePath)
|
bool NzFile::SetFile(const NzString& filePath)
|
||||||
{
|
|
||||||
if (IsOpen())
|
|
||||||
{
|
{
|
||||||
NazaraLock(m_mutex)
|
NazaraLock(m_mutex)
|
||||||
|
|
||||||
|
if (IsOpen())
|
||||||
|
{
|
||||||
if (filePath.IsEmpty())
|
if (filePath.IsEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
@ -445,6 +446,8 @@ bool NzFile::Write(const NzString& string)
|
||||||
|
|
||||||
std::size_t NzFile::Write(const void* buffer, std::size_t typeSize, unsigned int count)
|
std::size_t NzFile::Write(const void* buffer, std::size_t typeSize, unsigned int count)
|
||||||
{
|
{
|
||||||
|
NazaraLock(m_mutex)
|
||||||
|
|
||||||
#if NAZARA_CORE_SAFE
|
#if NAZARA_CORE_SAFE
|
||||||
if (!IsOpen())
|
if (!IsOpen())
|
||||||
{
|
{
|
||||||
|
|
@ -459,8 +462,6 @@ std::size_t NzFile::Write(const void* buffer, std::size_t typeSize, unsigned int
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
NazaraLock(m_mutex)
|
|
||||||
|
|
||||||
if (!buffer || count == 0 || typeSize == 0)
|
if (!buffer || count == 0 || typeSize == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
@ -732,7 +733,7 @@ bool NzFile::FillHash(NzAbstractHash* hash) const
|
||||||
unsigned int size;
|
unsigned int size;
|
||||||
while (remainingSize > 0)
|
while (remainingSize > 0)
|
||||||
{
|
{
|
||||||
size = std::min(remainingSize, static_cast<nzUInt64>(NAZARA_CORE_FILE_BUFFERSIZE));
|
size = static_cast<unsigned int>(std::min(remainingSize, static_cast<nzUInt64>(NAZARA_CORE_FILE_BUFFERSIZE)));
|
||||||
if (file.Read(&buffer[0], sizeof(char), size) != sizeof(char)*size)
|
if (file.Read(&buffer[0], sizeof(char), size) != sizeof(char)*size)
|
||||||
{
|
{
|
||||||
NazaraError("Unable to read file");
|
NazaraError("Unable to read file");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue