aboutsummaryrefslogtreecommitdiff
path: root/src/crepe
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-11-13 13:11:42 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-11-13 13:11:42 +0100
commit319d511135da1b58acb78ca939d7ee01fee4bbf3 (patch)
treeea2a417413ab4ca0cf8204ee9e517b89d842d81b /src/crepe
parentc58fbbefd5a426c38b1182e9e760f149f0091670 (diff)
move more files from `loek/tests` to `loek/audio`
Diffstat (limited to 'src/crepe')
-rw-r--r--src/crepe/Asset.cpp18
-rw-r--r--src/crepe/Asset.h2
2 files changed, 12 insertions, 8 deletions
diff --git a/src/crepe/Asset.cpp b/src/crepe/Asset.cpp
index 8a2a11c..3d4df53 100644
--- a/src/crepe/Asset.cpp
+++ b/src/crepe/Asset.cpp
@@ -1,16 +1,20 @@
#include <filesystem>
#include "Asset.h"
+#include "Exception.h"
using namespace crepe;
+using namespace std;
-Asset::Asset(const std::string & src) {
- // FIXME: restore this
- // this->src = std::filesystem::canonical(src);
- this->src = src;
- this->file = std::ifstream(this->src, std::ios::in | std::ios::binary);
+Asset::Asset(const string & src) : src(src) {
+ try {
+ this->src = filesystem::canonical(src);
+ } catch (filesystem::filesystem_error & e) {
+ throw Exception("Asset error: %s", e.what());
+ }
+ this->file = ifstream(this->src, ios::in | ios::binary);
}
-const std::istream & Asset::read() { return this->file; }
+const istream & Asset::read() { return this->file; }
-const char * Asset::canonical() { return this->src.c_str(); }
+const char * Asset::canonical() const { return this->src.c_str(); }
diff --git a/src/crepe/Asset.h b/src/crepe/Asset.h
index 0cb5834..d4e4ba1 100644
--- a/src/crepe/Asset.h
+++ b/src/crepe/Asset.h
@@ -23,7 +23,7 @@ public:
//! Get an input stream to the contents of this resource
const std::istream & read();
//! Get the canonical path to this resource
- const char * canonical();
+ const char * canonical() const;
private:
std::string src;