From 0ee45d7efb4081ada31bcf72bbffe0ddb1aeadff Mon Sep 17 00:00:00 2001 From: zetaPRIME Date: Sun, 22 Jan 2017 01:51:07 -0500 Subject: [PATCH] I'm not sure if a self-reference here is guaranteed to keep said "self" in scope...? --- libstarlight/source/starlight/util/Path.cpp | 13 +++++++++++++ libstarlight/source/starlight/util/Path.h | 7 ++++++- testbed/source/Core.cpp | 3 ++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/libstarlight/source/starlight/util/Path.cpp b/libstarlight/source/starlight/util/Path.cpp index a154dcb..9a31917 100644 --- a/libstarlight/source/starlight/util/Path.cpp +++ b/libstarlight/source/starlight/util/Path.cpp @@ -11,6 +11,8 @@ using std::getline; using starlight::util::Path; +string Path::destructed = ""; + Path::Path(const string& path, bool noverify) { if (noverify) { strpath = path; return; } size_t sls = path.find('/'); @@ -24,6 +26,11 @@ Path::Path(const Path& path) { strpath = path.strpath; // no need to check here! } +Path::~Path() { + destructed.append(strpath); + destructed.append("\n"); +} + Path Path::Up(int levels) { if (levels < 1) return *this; size_t spos = IsDirPath() ? strpath.length() - 1 : string::npos; @@ -58,3 +65,9 @@ Path Path::Combine(const string& token) { } return Path(path, true); } + +Path& Path::CreateDirectory() { + // todo: actually create the directory :D + + return *this; +} diff --git a/libstarlight/source/starlight/util/Path.h b/libstarlight/source/starlight/util/Path.h index 097f5f1..b145a43 100644 --- a/libstarlight/source/starlight/util/Path.h +++ b/libstarlight/source/starlight/util/Path.h @@ -13,14 +13,19 @@ namespace starlight { public: // vars... + static std::string destructed; Path(const std::string& path, bool noverify = false); Path(const Path& path); - ~Path() = default; + ~Path(); + // navigation Path Up(int levels = 1); Path Combine(const std::string& token); + // operation + Path& CreateDirectory(); + // semi-obsolete but whatever, it can stay for now inline bool IsDirPath() const { return strpath.back() == '/'; } diff --git a/testbed/source/Core.cpp b/testbed/source/Core.cpp index 58a0f36..b8cfaec 100644 --- a/testbed/source/Core.cpp +++ b/testbed/source/Core.cpp @@ -71,7 +71,8 @@ void Core::Init() { auto pipf = std::make_shared(VRect(0,0,400,240)); pipf->SetFont("default.16"); pipf->borderColor = Color::black; //pipf->SetText("I am the very model of something on the top screen. :D\nLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."); - pipf->SetText(Path("sdmc:/banana/algorithm/").Combine("porcupine/kumquat/romfs:/annual/sdmc:/puffin/pie")); + Path("sdmc:/banana/algorithm/").Combine("porcupine/kumquat/romfs:/annual/sdmc:/puffin/pie").CreateDirectory().CreateDirectory().Combine("farticus").Combine("platypus").CreateDirectory().Up(); + pipf->SetText(Path::destructed); parallax->Add(pipf); clearColor = Color(0.0f, 0.5f, 0.5f);