2014-02-02 20:42:32 +01:00
|
|
|
#include "stdafx.h"
|
2014-06-02 19:27:24 +02:00
|
|
|
#include "vfsDevice.h"
|
2014-02-02 20:42:32 +01:00
|
|
|
#include "vfsLocalDir.h"
|
|
|
|
|
|
2014-02-16 16:19:06 +01:00
|
|
|
vfsLocalDir::vfsLocalDir(vfsDevice* device) : vfsDirBase(device)
|
2014-02-02 20:42:32 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
vfsLocalDir::~vfsLocalDir()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-01 02:33:55 +02:00
|
|
|
bool vfsLocalDir::Open(const std::string& path)
|
2014-02-02 20:42:32 +01:00
|
|
|
{
|
|
|
|
|
if(!vfsDirBase::Open(path))
|
|
|
|
|
return false;
|
|
|
|
|
|
2014-05-02 08:30:32 +02:00
|
|
|
rDir dir;
|
2014-02-02 20:42:32 +01:00
|
|
|
|
|
|
|
|
if(!dir.Open(path))
|
|
|
|
|
return false;
|
|
|
|
|
|
2014-05-02 08:30:32 +02:00
|
|
|
std::string name;
|
2014-02-02 20:42:32 +01:00
|
|
|
for(bool is_ok = dir.GetFirst(&name); is_ok; is_ok = dir.GetNext(&name))
|
|
|
|
|
{
|
2014-05-02 08:30:32 +02:00
|
|
|
std::string dir_path = path + name;
|
2014-02-02 20:42:32 +01:00
|
|
|
|
2014-04-10 00:54:32 +02:00
|
|
|
m_entries.emplace_back();
|
|
|
|
|
DirEntryInfo& info = m_entries.back();
|
2014-05-02 08:30:32 +02:00
|
|
|
info.name = name;
|
2014-02-02 20:42:32 +01:00
|
|
|
|
2014-02-22 03:53:06 +01:00
|
|
|
info.flags |= dir.Exists(dir_path) ? DirEntry_TypeDir : DirEntry_TypeFile;
|
2014-05-02 08:30:32 +02:00
|
|
|
if(rIsWritable(dir_path)) info.flags |= DirEntry_PermWritable;
|
|
|
|
|
if(rIsReadable(dir_path)) info.flags |= DirEntry_PermReadable;
|
|
|
|
|
if(rIsExecutable(dir_path)) info.flags |= DirEntry_PermExecutable;
|
2014-02-02 20:42:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-01 02:33:55 +02:00
|
|
|
bool vfsLocalDir::Create(const std::string& path)
|
2014-02-02 20:42:32 +01:00
|
|
|
{
|
2014-05-02 08:30:32 +02:00
|
|
|
return rFileName::Mkdir(path, 0777, rPATH_MKDIR_FULL);
|
2014-02-02 20:42:32 +01:00
|
|
|
}
|
|
|
|
|
|
2014-04-01 02:33:55 +02:00
|
|
|
bool vfsLocalDir::Rename(const std::string& from, const std::string& to)
|
2014-02-02 20:42:32 +01:00
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-01 02:33:55 +02:00
|
|
|
bool vfsLocalDir::Remove(const std::string& path)
|
2014-02-02 20:42:32 +01:00
|
|
|
{
|
2014-05-02 08:30:32 +02:00
|
|
|
return rRmdir(path);
|
2014-02-23 17:52:52 +01:00
|
|
|
}
|