Files
Seele/src/Engine/Asset/Asset.cpp
T

64 lines
1.2 KiB
C++
Raw Normal View History

2020-05-05 01:51:13 +02:00
#include "Asset.h"
2020-09-19 14:36:50 +02:00
#include "AssetRegistry.h"
2020-05-05 01:51:13 +02:00
using namespace Seele;
Asset::Asset()
2020-06-02 11:46:18 +02:00
: fullPath("")
, name("")
, parentDir("")
, extension("")
, status(Status::Uninitialized)
2022-01-12 14:40:26 +01:00
, byteSize(0)
2020-06-02 11:46:18 +02:00
{
}
Asset::Asset(const std::filesystem::path& path)
2020-09-19 14:36:50 +02:00
: status(Status::Uninitialized)
2020-06-02 11:46:18 +02:00
{
2020-09-19 14:36:50 +02:00
if(path.is_absolute())
{
fullPath = path;
}
else
{
fullPath = AssetRegistry::getRootFolder();
fullPath.append(path.generic_string());
}
2020-06-02 11:46:18 +02:00
fullPath.make_preferred();
parentDir = fullPath.parent_path();
name = fullPath.stem();
extension = fullPath.extension();
}
Asset::Asset(const std::string &directory, const std::string &fileName)
: Asset(std::filesystem::path(directory + fileName))
2020-05-05 01:51:13 +02:00
{
}
Asset::~Asset()
{
2020-06-02 11:46:18 +02:00
}
2022-04-13 13:01:35 +02:00
std::ifstream Asset::getReadStream() const
2020-06-02 11:46:18 +02:00
{
2022-04-13 13:01:35 +02:00
return std::ifstream(fullPath);
2020-06-02 11:46:18 +02:00
}
2022-04-13 13:01:35 +02:00
std::ofstream Asset::getWriteStream() const
2020-06-02 11:46:18 +02:00
{
2022-04-13 13:01:35 +02:00
return std::ofstream(fullPath);
2020-06-02 11:46:18 +02:00
}
2020-09-19 14:36:50 +02:00
std::string Asset::getFileName() const
2020-06-02 11:46:18 +02:00
{
return name.generic_string();
}
2020-09-19 14:36:50 +02:00
std::string Asset::getFullPath() const
2020-06-02 11:46:18 +02:00
{
return fullPath.generic_string();
}
2020-09-19 14:36:50 +02:00
std::string Asset::getExtension() const
2020-06-02 11:46:18 +02:00
{
return extension.generic_string();
2020-05-05 01:51:13 +02:00
}