Tidy up some xml structures.

This commit is contained in:
jmsgrogan 2020-05-09 15:29:45 +01:00
parent 875cdc84ff
commit 8771b721d1
31 changed files with 885 additions and 563 deletions

View file

@ -0,0 +1,68 @@
#include "File.h"
#include "FileLogger.h"
File::File(std::filesystem::path path)
: mFullPath(path),
mInHandle(),
mOutHandle(),
mAccessMode(AccessMode::Read)
{
}
std::string File::GetExtension() const
{
return mFullPath.extension();
}
void File::SetAccessMode(AccessMode mode)
{
mAccessMode = mode;
}
std::ifstream* File::GetInHandle() const
{
return mInHandle.get();
}
std::ofstream* File::GetOutHandle() const
{
return mOutHandle.get();
}
void File::Open()
{
if(mAccessMode == AccessMode::Read)
{
mInHandle = std::make_unique<std::ifstream>();
mInHandle->open(mFullPath, std::ifstream::in);
}
else
{
mOutHandle = std::make_unique<std::ofstream>();
mOutHandle->open(mFullPath, std::ofstream::out);
}
}
void File::Close()
{
if(mOutHandle)
{
mOutHandle->close();
}
if(mInHandle)
{
mInHandle->close();
}
}
FileFormat::Format File::InferFormat() const
{
const auto extension = GetExtension();
return FileFormat::InferFormat(extension);
}
bool File::PathExists() const
{
return std::filesystem::exists(mFullPath);
}