2013-06-30 10:46:29 +02:00
|
|
|
#include "stdafx.h"
|
2015-04-24 23:38:11 +02:00
|
|
|
#include "Utilities/File.h"
|
2014-08-25 20:09:48 +02: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-11-29 14:16:53 +01:00
|
|
|
return false;
|
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
|
|
|
}
|
2014-11-29 14:16:53 +01:00
|
|
|
|
|
|
|
|
const DirEntryInfo* vfsDirBase::First()
|
|
|
|
|
{
|
|
|
|
|
m_pos = 0;
|
|
|
|
|
return Read();
|
2015-04-19 21:25:04 +02:00
|
|
|
}
|