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
|
|
|
{
|
2015-04-25 21:15:53 +02:00
|
|
|
if (!vfsDirBase::Open(path) || !m_dir.open(path))
|
2015-04-15 16:27:37 +02:00
|
|
|
{
|
2014-02-02 20:42:32 +01:00
|
|
|
return false;
|
2015-04-15 16:27:37 +02:00
|
|
|
}
|
2014-02-02 20:42:32 +01:00
|
|
|
|
2014-05-02 08:30:32 +02:00
|
|
|
std::string name;
|
2015-04-25 21:15:53 +02:00
|
|
|
fs::stat_t file_info;
|
2015-04-15 16:27:37 +02:00
|
|
|
|
2016-01-06 00:52:48 +01:00
|
|
|
while (m_dir.read(name, file_info) && name.size())
|
2014-02-02 20:42:32 +01:00
|
|
|
{
|
2014-04-10 00:54:32 +02:00
|
|
|
m_entries.emplace_back();
|
2014-02-02 20:42:32 +01:00
|
|
|
|
2015-04-15 16:27:37 +02:00
|
|
|
DirEntryInfo& info = m_entries.back();
|
2014-07-31 20:20:00 +02:00
|
|
|
|
2015-04-15 16:27:37 +02:00
|
|
|
info.name = name;
|
2015-04-24 23:38:11 +02:00
|
|
|
info.flags |= file_info.is_directory ? DirEntry_TypeDir | DirEntry_PermExecutable : DirEntry_TypeFile;
|
|
|
|
|
info.flags |= file_info.is_writable ? DirEntry_PermWritable | DirEntry_PermReadable : DirEntry_PermReadable;
|
2015-04-15 16:27:37 +02:00
|
|
|
info.size = file_info.size;
|
|
|
|
|
info.access_time = file_info.atime;
|
|
|
|
|
info.modify_time = file_info.mtime;
|
|
|
|
|
info.create_time = file_info.ctime;
|
2014-02-02 20:42:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-06 00:34:26 +02:00
|
|
|
bool vfsLocalDir::IsOpened() const
|
|
|
|
|
{
|
2015-04-25 21:15:53 +02:00
|
|
|
return m_dir && vfsDirBase::IsOpened();
|
2014-08-06 00:34:26 +02:00
|
|
|
}
|