bool NzDirectory::NextResult(bool skipDots) { NazaraLock(m_mutex); #if NAZARA_CORE_SAFE if (!m_impl) { NazaraError("Directory not opened"); return false; } #endif NzString name; do { if (!m_impl->NextResult()) return false; name = m_impl->GetResultName(); if (skipDots && (name == '.' || name == "..")) continue; if (name.Match(m_pattern)) break; } while (true); return true; }
void NzDirectory::SetDirectory(const NzString& dirPath) { NazaraLock(m_mutex); Close(); m_dirPath = NzFile::AbsolutePath(dirPath); }
/*! * \brief Restart the clock * Restarts the clock, putting it's time counter back to zero (as if the clock got constructed). */ void Clock::Restart() { NazaraLock(m_mutex); m_elapsedTime = 0; m_refTime = GetElapsedMicroseconds(); m_paused = false; }
bool NzDirectory::Exists() const { NazaraLock(m_mutex); if (IsOpen()) return true; // Le fichier est ouvert, donc il existe else return Exists(m_dirPath); }
/*! * \brief Pause the clock * * Pauses the clock, making the time retrieving functions to always return the value at the time the clock was paused * This has no effect if the clock is already paused * * \see IsPaused, Unpause */ void Clock::Pause() { NazaraLock(m_mutex); if (!m_paused) { m_elapsedTime += GetElapsedMicroseconds() - m_refTime; m_paused = true; } }
/*! * \brief Unpause the clock * * Unpauses the clock, making the clock continue to measure the time * This has no effect if the clock is already unpaused * * \see IsPaused, Unpause */ void Clock::Unpause() { NazaraLock(m_mutex); if (m_paused) { m_refTime = GetElapsedMicroseconds(); m_paused = false; } }
/*! * Returns the elapsed time in microseconds * \return Microseconds elapsed * * \see GetMilliseconds, GetSeconds */ UInt64 Clock::GetMicroseconds() const { NazaraLock(m_mutex); UInt64 elapsedMicroseconds = m_elapsedTime; if (!m_paused) elapsedMicroseconds += (GetElapsedMicroseconds() - m_refTime); return elapsedMicroseconds; }
void NzDirectory::Close() { NazaraLock(m_mutex); if (m_impl) { m_impl->Close(); delete m_impl; m_impl = nullptr; } }
void NzClock::Unpause() { NazaraLock(m_mutex); if (m_paused) { m_refTime = NzGetMicroseconds(); m_paused = false; } else NazaraWarning("Clock is not paused, ignoring..."); }
void NzClock::Pause() { NazaraLock(m_mutex); if (!m_paused) { m_elapsedTime += NzGetMicroseconds()-m_refTime; m_paused = true; } else NazaraWarning("Clock is already paused, ignoring..."); }
nzUInt64 NzDirectory::GetResultSize() const { NazaraLock(m_mutex); #if NAZARA_CORE_SAFE if (!m_impl) { NazaraError("Directory not opened"); return 0; } #endif return m_impl->GetResultSize(); }
NzString NzDirectory::GetResultPath() const { NazaraLock(m_mutex); #if NAZARA_CORE_SAFE if (!m_impl) { NazaraError("Directory not opened"); return NzString(); } #endif return m_dirPath + NAZARA_DIRECTORY_SEPARATOR + m_impl->GetResultName(); }
bool NzDirectory::IsResultDirectory() const { NazaraLock(m_mutex); #if NAZARA_CORE_SAFE if (!m_impl) { NazaraError("Directory not opened"); return false; } #endif return m_impl->IsResultDirectory(); }
/*! * \brief Restart the clock * \return Microseconds elapsed * * Restarts the clock, putting it's time counter back to zero (as if the clock got constructed). * It also compute the elapsed microseconds since the last Restart() call without any time loss (a problem that the combination of GetElapsedMicroseconds and Restart have). */ UInt64 Clock::Restart() { NazaraLock(m_mutex); Nz::UInt64 now = GetElapsedMicroseconds(); Nz::UInt64 elapsedTime = m_elapsedTime; if (!m_paused) elapsedTime += (now - m_refTime); m_elapsedTime = 0; m_refTime = now; m_paused = false; return elapsedTime; }
bool NzDirectory::Open() { NazaraLock(m_mutex); Close(); if (!Exists(m_dirPath)) return false; m_impl = new NzDirectoryImpl(this); if (!m_impl->Open(m_dirPath)) { delete m_impl; m_impl = nullptr; return false; } return true; }
void NzDirectory::SetPattern(const NzString& pattern) { NazaraLock(m_mutex); m_pattern = pattern; }
bool NzDirectory::IsOpen() const { NazaraLock(m_mutex); return m_impl != nullptr; }
/*! * Returns the current pause state of the clock * \return Boolean indicating if the clock is currently paused * * \see Pause, Unpause */ bool Clock::IsPaused() const { NazaraLock(m_mutex); return m_paused; }
NzString NzDirectory::GetPattern() const { NazaraLock(m_mutex); return m_pattern; }