Initial metadata parsing
This commit is contained in:
parent
ebd41bf4ee
commit
7216fc5ab0
8 changed files with 276 additions and 145 deletions
|
@ -79,6 +79,27 @@ void File::WriteText(const std::string& text)
|
|||
(*mOutHandle) << text;
|
||||
}
|
||||
|
||||
std::vector<std::string> File::readLines()
|
||||
{
|
||||
std::vector<std::string> content;
|
||||
|
||||
if (!PathExists())
|
||||
{
|
||||
return content;
|
||||
}
|
||||
|
||||
Open(false);
|
||||
|
||||
std::string str;
|
||||
while(std::getline(*mInHandle, str))
|
||||
{
|
||||
content.push_back(str);
|
||||
}
|
||||
|
||||
Close();
|
||||
return content;
|
||||
}
|
||||
|
||||
std::string File::ReadText()
|
||||
{
|
||||
std::string str((std::istreambuf_iterator<char>(*mInHandle)),
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
#include "FileFormats.h"
|
||||
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
#include "FileFormats.h"
|
||||
#include <fstream>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
class File
|
||||
{
|
||||
|
@ -13,13 +16,6 @@ public:
|
|||
Write
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
std::filesystem::path mFullPath;
|
||||
std::unique_ptr<std::ifstream> mInHandle;
|
||||
std::unique_ptr<std::ofstream> mOutHandle;
|
||||
AccessMode mAccessMode;
|
||||
|
||||
public:
|
||||
|
||||
File(std::filesystem::path fullPath);
|
||||
|
@ -36,6 +32,8 @@ public:
|
|||
|
||||
std::string ReadText();
|
||||
|
||||
std::vector<std::string> readLines();
|
||||
|
||||
bool PathExists() const;
|
||||
|
||||
void SetAccessMode(AccessMode mode);
|
||||
|
@ -44,4 +42,12 @@ public:
|
|||
|
||||
void Close();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
std::filesystem::path mFullPath;
|
||||
std::unique_ptr<std::ifstream> mInHandle;
|
||||
std::unique_ptr<std::ofstream> mOutHandle;
|
||||
AccessMode mAccessMode;
|
||||
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue