rpcsx/rpcs3/Emu/FS/vfsLocalDir.cpp

65 lines
1.3 KiB
C++
Raw Normal View History

#include "stdafx.h"
#include "vfsDevice.h"
#include "vfsLocalDir.h"
vfsLocalDir::vfsLocalDir(vfsDevice* device) : vfsDirBase(device)
{
}
vfsLocalDir::~vfsLocalDir()
{
}
bool vfsLocalDir::Open(const std::string& path)
{
2015-04-25 21:15:53 +02:00
if (!vfsDirBase::Open(path) || !m_dir.open(path))
2015-04-15 16:27:37 +02:00
{
return false;
2015-04-15 16:27:37 +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
2015-04-25 21:15:53 +02:00
for (bool is_ok = m_dir.get_first(name, file_info); is_ok; is_ok = m_dir.get_next(name, file_info))
{
m_entries.emplace_back();
2015-04-15 16:27:37 +02:00
DirEntryInfo& info = m_entries.back();
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;
}
return true;
}
bool vfsLocalDir::Create(const std::string& path)
{
2015-04-24 23:38:11 +02:00
return fs::create_dir(path);
}
2014-11-29 14:16:53 +01:00
bool vfsLocalDir::IsExists(const std::string& path) const
{
2015-04-24 23:38:11 +02:00
return fs::is_dir(path);
2014-11-29 14:16:53 +01:00
}
bool vfsLocalDir::Rename(const std::string& from, const std::string& to)
{
2015-04-24 23:38:11 +02:00
return fs::rename(from, to);
}
bool vfsLocalDir::Remove(const std::string& path)
{
2015-04-24 23:38:11 +02:00
return fs::remove_dir(path);
}
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
}