2014-02-16 16:19:06 +01:00
|
|
|
#include "stdafx.h"
|
2014-06-02 19:27:24 +02:00
|
|
|
#include "Emu/System.h"
|
|
|
|
|
|
2014-08-26 01:55:37 +02:00
|
|
|
#include "VFS.h"
|
2014-02-16 16:19:06 +01:00
|
|
|
#include "vfsDir.h"
|
|
|
|
|
|
|
|
|
|
vfsDir::vfsDir()
|
|
|
|
|
: vfsDirBase(nullptr)
|
|
|
|
|
, m_stream(nullptr)
|
|
|
|
|
{
|
2014-07-14 19:21:24 +02:00
|
|
|
// TODO: proper implementation
|
|
|
|
|
// m_stream is nullptr here. So open root until a proper dir is given
|
|
|
|
|
Open("/");
|
2014-02-16 16:19:06 +01:00
|
|
|
}
|
|
|
|
|
|
2014-04-01 02:33:55 +02:00
|
|
|
vfsDir::vfsDir(const std::string& path)
|
2014-02-16 16:19:06 +01:00
|
|
|
: vfsDirBase(nullptr)
|
|
|
|
|
, m_stream(nullptr)
|
|
|
|
|
{
|
|
|
|
|
Open(path);
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-01 02:33:55 +02:00
|
|
|
bool vfsDir::Open(const std::string& path)
|
2014-02-16 16:19:06 +01:00
|
|
|
{
|
|
|
|
|
Close();
|
|
|
|
|
|
2014-02-16 16:37:32 +01:00
|
|
|
m_stream.reset(Emu.GetVFS().OpenDir(path));
|
2014-02-16 16:19:06 +01:00
|
|
|
|
|
|
|
|
return m_stream && m_stream->IsOpened();
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-01 02:33:55 +02:00
|
|
|
bool vfsDir::Create(const std::string& path)
|
2014-02-16 16:19:06 +01:00
|
|
|
{
|
|
|
|
|
return m_stream->Create(path);
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-01 02:33:55 +02:00
|
|
|
bool vfsDir::IsExists(const std::string& path) const
|
2014-02-16 16:19:06 +01:00
|
|
|
{
|
2014-07-14 19:21:24 +02:00
|
|
|
return m_stream->IsExists(path);
|
2014-02-16 16:19:06 +01:00
|
|
|
}
|
|
|
|
|
|
2014-04-10 00:54:32 +02:00
|
|
|
const std::vector<DirEntryInfo>& vfsDir::GetEntries() const
|
2014-02-16 16:19:06 +01:00
|
|
|
{
|
|
|
|
|
return m_stream->GetEntries();
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-01 02:33:55 +02:00
|
|
|
bool vfsDir::Rename(const std::string& from, const std::string& to)
|
2014-02-16 16:19:06 +01:00
|
|
|
{
|
|
|
|
|
return m_stream->Rename(from, to);
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-01 02:33:55 +02:00
|
|
|
bool vfsDir::Remove(const std::string& path)
|
2014-02-16 16:19:06 +01:00
|
|
|
{
|
|
|
|
|
return m_stream->Remove(path);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const DirEntryInfo* vfsDir::Read()
|
|
|
|
|
{
|
|
|
|
|
return m_stream->Read();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void vfsDir::Close()
|
|
|
|
|
{
|
|
|
|
|
m_stream.reset();
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-01 02:33:55 +02:00
|
|
|
std::string vfsDir::GetPath() const
|
2014-02-16 16:19:06 +01:00
|
|
|
{
|
|
|
|
|
return m_stream->GetPath();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool vfsDir::IsOpened() const
|
|
|
|
|
{
|
2014-02-22 03:53:06 +01:00
|
|
|
return m_stream && m_stream->IsOpened();
|
2014-02-16 16:19:06 +01:00
|
|
|
}
|