Adding nlohmanns json library
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
#include "Asset.h"
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
Asset::Asset()
|
||||
{
|
||||
}
|
||||
|
||||
Asset::~Asset()
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
#include "MinimalEngine.h"
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
class Asset
|
||||
{
|
||||
public:
|
||||
Asset();
|
||||
virtual ~Asset();
|
||||
|
||||
private:
|
||||
};
|
||||
DEFINE_REF(Asset);
|
||||
} // namespace Seele
|
||||
@@ -0,0 +1,6 @@
|
||||
target_sources(SeeleEngine
|
||||
PRIVATE
|
||||
Asset.h
|
||||
Asset.cpp
|
||||
FileAsset.h
|
||||
FileAsset.cpp)
|
||||
@@ -0,0 +1,62 @@
|
||||
#include "FileAsset.h"
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
FileAsset::FileAsset()
|
||||
: path("")
|
||||
, name("")
|
||||
{
|
||||
}
|
||||
|
||||
FileAsset::FileAsset(const std::string &fullPath)
|
||||
: path(fullPath)
|
||||
{
|
||||
name = fullPath.substr(fullPath.find_last_of('\\')+1);
|
||||
}
|
||||
|
||||
FileAsset::FileAsset(const std::string &directory, const std::string &name)
|
||||
: path(directory+name)
|
||||
, name(name)
|
||||
{
|
||||
}
|
||||
|
||||
FileAsset::~FileAsset()
|
||||
{
|
||||
}
|
||||
|
||||
std::ifstream &FileAsset::getReadStream()
|
||||
{
|
||||
if(inStream.is_open())
|
||||
{
|
||||
return inStream;
|
||||
}
|
||||
inStream.open(path);
|
||||
return inStream;
|
||||
}
|
||||
|
||||
std::ofstream &FileAsset::getWriteStream()
|
||||
{
|
||||
if(outStream.is_open())
|
||||
{
|
||||
return outStream;
|
||||
}
|
||||
outStream.open(path);
|
||||
return outStream;
|
||||
}
|
||||
|
||||
void FileAsset::rename(const std::string& newName)
|
||||
{
|
||||
if(inStream.is_open())
|
||||
{
|
||||
inStream.close();
|
||||
}
|
||||
if(outStream.is_open())
|
||||
{
|
||||
outStream.flush();
|
||||
outStream.close();
|
||||
}
|
||||
path.replace(path.find_last_of(name), name.size(), newName);
|
||||
name = newName;
|
||||
inStream.open(path);
|
||||
outStream.open(path);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
#include "Asset.h"
|
||||
#include <fstream>
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
class FileAsset
|
||||
{
|
||||
public:
|
||||
FileAsset();
|
||||
FileAsset(const std::string& directory, const std::string& name);
|
||||
FileAsset(const std::string& fullPath);
|
||||
virtual ~FileAsset();
|
||||
std::ifstream& getReadStream();
|
||||
std::ofstream& getWriteStream();
|
||||
void rename(const std::string& newName);
|
||||
private:
|
||||
std::string name;
|
||||
std::string path;
|
||||
uint32 byteSize;
|
||||
std::ifstream inStream;
|
||||
std::ofstream outStream;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user