Example #1
0
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;
}
Example #2
0
void NzDirectory::SetDirectory(const NzString& dirPath)
{
	NazaraLock(m_mutex);

	Close();

	m_dirPath = NzFile::AbsolutePath(dirPath);
}
Example #3
0
	/*!
	* \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;
	}
Example #4
0
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;
	}
Example #8
0
void NzDirectory::Close()
{
	NazaraLock(m_mutex);

	if (m_impl)
	{
		m_impl->Close();
		delete m_impl;
		m_impl = nullptr;
	}
}
Example #9
0
void NzClock::Unpause()
{
	NazaraLock(m_mutex);

	if (m_paused)
	{
		m_refTime = NzGetMicroseconds();
		m_paused = false;
	}
	else
		NazaraWarning("Clock is not paused, ignoring...");
}
Example #10
0
void NzClock::Pause()
{
	NazaraLock(m_mutex);

	if (!m_paused)
	{
		m_elapsedTime += NzGetMicroseconds()-m_refTime;
		m_paused = true;
	}
	else
		NazaraWarning("Clock is already paused, ignoring...");
}
Example #11
0
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();
}
Example #12
0
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();
}
Example #13
0
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;
	}
Example #15
0
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;
}
Example #16
0
void NzDirectory::SetPattern(const NzString& pattern)
{
	NazaraLock(m_mutex);

	m_pattern = pattern;
}
Example #17
0
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;
	}
Example #19
0
NzString NzDirectory::GetPattern() const
{
	NazaraLock(m_mutex);

	return m_pattern;
}