2013-06-30 10:46:29 +02:00
|
|
|
#include "stdafx.h"
|
2014-06-02 19:27:24 +02:00
|
|
|
#include "vfsDevice.h"
|
2013-11-19 11:30:58 +01:00
|
|
|
#include "vfsDirBase.h"
|
2013-06-30 10:46:29 +02:00
|
|
|
|
2014-02-16 16:19:06 +01:00
|
|
|
vfsDirBase::vfsDirBase(vfsDevice* device)
|
|
|
|
|
: m_pos(0)
|
|
|
|
|
, m_device(device)
|
2014-02-02 20:42:32 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
vfsDirBase::~vfsDirBase()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-01 02:33:55 +02:00
|
|
|
bool vfsDirBase::Open(const std::string& path)
|
2014-02-02 20:42:32 +01:00
|
|
|
{
|
2014-02-22 03:53:06 +01:00
|
|
|
if(IsOpened())
|
2014-02-02 20:42:32 +01:00
|
|
|
Close();
|
|
|
|
|
|
|
|
|
|
if(!IsExists(path))
|
|
|
|
|
return false;
|
|
|
|
|
|
2014-02-16 16:19:06 +01:00
|
|
|
m_pos = 0;
|
2014-02-02 20:42:32 +01: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 20:42:32 +01:00
|
|
|
}
|
|
|
|
|
|
2014-04-01 02:33:55 +02:00
|
|
|
bool vfsDirBase::IsExists(const std::string& path) const
|
2014-02-02 20:42:32 +01:00
|
|
|
{
|
2014-05-02 08:30:32 +02:00
|
|
|
return rDirExists(path);
|
2014-02-09 22:53:48 +01: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 20:42:32 +01: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 20:42:32 +01:00
|
|
|
}
|
|
|
|
|
|
2014-04-01 02:33:55 +02:00
|
|
|
std::string vfsDirBase::GetPath() const
|
2014-02-02 20:42:32 +01:00
|
|
|
{
|
|
|
|
|
return m_cwd;
|
2014-02-16 16:19:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const DirEntryInfo* vfsDirBase::Read()
|
|
|
|
|
{
|
2014-04-10 00:54:32 +02:00
|
|
|
if (m_pos >= m_entries.size())
|
2014-02-16 16:19:06 +01:00
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
|
|
return &m_entries[m_pos++];
|
2014-04-10 00:54:32 +02:00
|
|
|
}
|