2013-06-30 11:46:29 +03:00
|
|
|
#include "stdafx.h"
|
2015-04-25 00:38:11 +03:00
|
|
|
#include "Utilities/File.h"
|
2014-08-25 22:09:48 +04:00
|
|
|
#include "vfsDirBase.h"
|
2013-06-30 11:46:29 +03:00
|
|
|
|
2014-02-16 17:19:06 +02:00
|
|
|
vfsDirBase::vfsDirBase(vfsDevice* device)
|
|
|
|
|
: m_pos(0)
|
|
|
|
|
, m_device(device)
|
2014-02-02 21:42:32 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
vfsDirBase::~vfsDirBase()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-01 02:33:55 +02:00
|
|
|
bool vfsDirBase::Open(const std::string& path)
|
2014-02-02 21:42:32 +02:00
|
|
|
{
|
2015-08-08 16:17:28 +03:00
|
|
|
if (IsOpened())
|
|
|
|
|
{
|
2014-02-02 21:42:32 +02:00
|
|
|
Close();
|
2015-08-08 16:17:28 +03:00
|
|
|
}
|
2014-02-02 21:42:32 +02:00
|
|
|
|
2014-02-16 17:19:06 +02:00
|
|
|
m_pos = 0;
|
2014-02-02 21:42:32 +02:00
|
|
|
m_cwd += '/' + path;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool vfsDirBase::IsOpened() const
|
|
|
|
|
{
|
2014-04-01 02:33:55 +02:00
|
|
|
return !m_cwd.empty();
|
2014-02-02 21:42:32 +02:00
|
|
|
}
|
|
|
|
|
|
2014-04-10 00:54:32 +02:00
|
|
|
const std::vector<DirEntryInfo>& vfsDirBase::GetEntries() const
|
2014-02-09 22:53:48 +01:00
|
|
|
{
|
|
|
|
|
return m_entries;
|
2014-02-02 21:42:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void vfsDirBase::Close()
|
|
|
|
|
{
|
2014-04-01 02:33:55 +02:00
|
|
|
m_cwd = "";
|
2014-04-10 00:54:32 +02:00
|
|
|
m_entries.clear();
|
2014-02-02 21:42:32 +02:00
|
|
|
}
|
|
|
|
|
|
2014-04-01 02:33:55 +02:00
|
|
|
std::string vfsDirBase::GetPath() const
|
2014-02-02 21:42:32 +02:00
|
|
|
{
|
|
|
|
|
return m_cwd;
|
2014-02-16 17:19:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const DirEntryInfo* vfsDirBase::Read()
|
|
|
|
|
{
|
2014-04-10 00:54:32 +02:00
|
|
|
if (m_pos >= m_entries.size())
|
2014-02-16 17:19:06 +02:00
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
|
|
return &m_entries[m_pos++];
|
2014-04-10 00:54:32 +02:00
|
|
|
}
|
2014-11-29 15:16:53 +02:00
|
|
|
|
|
|
|
|
const DirEntryInfo* vfsDirBase::First()
|
|
|
|
|
{
|
|
|
|
|
m_pos = 0;
|
|
|
|
|
return Read();
|
2015-04-19 22:25:04 +03:00
|
|
|
}
|