diff --git a/projects/WinDurango.Common/CMakeLists.txt b/projects/WinDurango.Common/CMakeLists.txt
index 6d6c78a..541a3a6 100644
--- a/projects/WinDurango.Common/CMakeLists.txt
+++ b/projects/WinDurango.Common/CMakeLists.txt
@@ -23,7 +23,8 @@ FetchContent_MakeAvailable(json)
add_library(WinDurango.Common SHARED ${FILES})
target_include_directories(WinDurango.Common PUBLIC
- $
+ $
+ $
)
target_link_libraries(WinDurango.Common PUBLIC nlohmann_json::nlohmann_json)
diff --git a/projects/WinDurango.Common/include/WinDurango.Common/Config.h b/projects/WinDurango.Common/include/WinDurango.Common/Config.h
index 45498fb..f1f6e90 100644
--- a/projects/WinDurango.Common/include/WinDurango.Common/Config.h
+++ b/projects/WinDurango.Common/include/WinDurango.Common/Config.h
@@ -6,18 +6,31 @@
#include
#include
#include
+#include "Interfaces/Storage/File.h"
+/*
+ * TODO: Make it to write back
+*/
namespace wd::common {
class Config {
public:
- Config() {}
- Config(std::string file, bool ReadOnly = false) {}
+ Config() : pFile(nullptr), RO(false) {}
+ Config(std::shared_ptr file, bool ReadOnly = false) : pFile(file), RO(ReadOnly) {}
+
+ bool parse();
/*
* Operator Overloading
* https://en.cppreference.com/w/cpp/language/operators.html
*/
template
- T& operator[](std::string node) {}
+ T& operator[](std::string node);
+
+ template
+ bool set(std::string node, T type);
+ private:
+ std::shared_ptr pFile;
+ bool RO;
+ nlohmann::json data;
};
}
diff --git a/projects/WinDurango.Common/include/WinDurango.Common/Interfaces/Storage/Directory.h b/projects/WinDurango.Common/include/WinDurango.Common/Interfaces/Storage/Directory.h
index 4e940c9..92eae04 100644
--- a/projects/WinDurango.Common/include/WinDurango.Common/Interfaces/Storage/Directory.h
+++ b/projects/WinDurango.Common/include/WinDurango.Common/Interfaces/Storage/Directory.h
@@ -3,6 +3,7 @@
//
#pragma once
#include
+#include
#include "File.h"
namespace wd::common::interfaces::storage {
@@ -19,8 +20,8 @@ namespace wd::common::interfaces::storage {
Directory() {}
virtual bool open() = 0;
- virtual File* CreateFile(std::filesystem::path path) = 0; // todo maybe return stream type, todo can we use this in uwp context??? I forgor
- virtual Directory* CreateFolder(std::filesystem::path path) = 0;
+ virtual std::shared_ptr CreateFile(std::filesystem::path path) = 0; // todo maybe return stream type, todo can we use this in uwp context??? I forgor
+ virtual std::shared_ptr CreateFolder(std::filesystem::path path) = 0;
virtual std::filesystem::path dirpath() = 0;
diff --git a/projects/WinDurango.Common/src/Config.cpp b/projects/WinDurango.Common/src/Config.cpp
new file mode 100644
index 0000000..bbe6ded
--- /dev/null
+++ b/projects/WinDurango.Common/src/Config.cpp
@@ -0,0 +1,24 @@
+#include "Config.h"
+
+bool wd::common::Config::parse() {
+ try {
+ std::string jsonData = pFile->read();
+ data = nlohmann::json::parse(jsonData);
+ return true;
+ } catch (const std::exception& e) {
+ return false;
+ } catch (...) {
+ return false;
+ }
+}
+
+template
+T& wd::common::Config::operator[](std::string node) {
+ return data[node];
+}
+
+template
+bool wd::common::Config::set(std::string node, T type) {
+ data[node] = type;
+ return true;
+}
\ No newline at end of file
diff --git a/projects/WinDurango.Implementation.WinRT/CMakeLists.txt b/projects/WinDurango.Implementation.WinRT/CMakeLists.txt
index 9e82a18..71fb6c6 100644
--- a/projects/WinDurango.Implementation.WinRT/CMakeLists.txt
+++ b/projects/WinDurango.Implementation.WinRT/CMakeLists.txt
@@ -11,6 +11,7 @@ set(FILES
include/WinDurango.Implementation.WinRT/Interfaces/Storage/File.h
src/interfaces/Storage/Directory.cpp
src/interfaces/Storage/File.cpp
+ src/WinRT.cpp
)
add_compile_definitions(WDIMPL_API_EXPORTS)
diff --git a/projects/WinDurango.Implementation.WinRT/include/WinDurango.Implementation.WinRT/Interfaces/Storage/Directory.h b/projects/WinDurango.Implementation.WinRT/include/WinDurango.Implementation.WinRT/Interfaces/Storage/Directory.h
index 0899219..ebe3100 100644
--- a/projects/WinDurango.Implementation.WinRT/include/WinDurango.Implementation.WinRT/Interfaces/Storage/Directory.h
+++ b/projects/WinDurango.Implementation.WinRT/include/WinDurango.Implementation.WinRT/Interfaces/Storage/Directory.h
@@ -19,8 +19,8 @@ namespace wd::impl::winrt::interfaces::storage {
WinRTDirectory(std::filesystem::path dirpath) : path(dirpath), dir(nullptr) {}
virtual bool open() override;
- virtual wd::common::interfaces::storage::File* CreateFile(std::filesystem::path path) override;
- virtual wd::common::interfaces::storage::Directory* CreateFolder(std::filesystem::path path) override;
+ virtual std::shared_ptr CreateFile(std::filesystem::path path) override;
+ virtual std::shared_ptr CreateFolder(std::filesystem::path path) override;
virtual std::filesystem::path dirpath() override;
diff --git a/projects/WinDurango.Implementation.WinRT/src/WinRT.cpp b/projects/WinDurango.Implementation.WinRT/src/WinRT.cpp
new file mode 100644
index 0000000..77296ff
--- /dev/null
+++ b/projects/WinDurango.Implementation.WinRT/src/WinRT.cpp
@@ -0,0 +1,11 @@
+#include
+#include
+#include "WinDurangoWinRT.h"
+
+/*
+ * Found here
+ * https://stackoverflow.com/questions/12168113/detect-application-running-in-winrt-mode-by-pid
+*/
+bool WDIMPL_API ImplementationSupported() {
+ return IsImmersiveProcess(GetCurrentProcess());
+}
\ No newline at end of file
diff --git a/projects/WinDurango.Implementation.WinRT/src/interfaces/Storage/Directory.cpp b/projects/WinDurango.Implementation.WinRT/src/interfaces/Storage/Directory.cpp
index 1f37120..7d5d361 100644
--- a/projects/WinDurango.Implementation.WinRT/src/interfaces/Storage/Directory.cpp
+++ b/projects/WinDurango.Implementation.WinRT/src/interfaces/Storage/Directory.cpp
@@ -33,13 +33,13 @@ bool wd::impl::winrt::interfaces::storage::WinRTDirectory::open() {
* TargetPath is the filename btw
* any path will be ignored.
*/
-wd::common::interfaces::storage::File* wd::impl::winrt::interfaces::storage::WinRTDirectory::CreateFile(std::filesystem::path targetPath) {
+std::shared_ptr wd::impl::winrt::interfaces::storage::WinRTDirectory::CreateFile(std::filesystem::path targetPath) {
if (dir == nullptr) {
return nullptr;
}
try {
auto file = dir.CreateFileAsync(hstring(targetPath.filename().wstring()), CreationCollisionOption::OpenIfExists).get();
- wd::impl::winrt::interfaces::storage::WinRTFile* fileRT = new wd::impl::winrt::interfaces::storage::WinRTFile(path / targetPath.filename());
+ std::shared_ptr fileRT = std::make_shared(path / targetPath.filename());
return fileRT;
}
catch (const hresult_error& ex) {
@@ -48,15 +48,15 @@ wd::common::interfaces::storage::File* wd::impl::winrt::interfaces::storage::Win
}
/*
- * TODO: Use Unique Pointers
+ * TODO: Use Shared Pointers
*/
-wd::common::interfaces::storage::Directory* wd::impl::winrt::interfaces::storage::WinRTDirectory::CreateFolder(std::filesystem::path targetPath) {
+std::shared_ptr wd::impl::winrt::interfaces::storage::WinRTDirectory::CreateFolder(std::filesystem::path targetPath) {
if (dir == nullptr) {
return nullptr;
}
try {
auto file = dir.CreateFolderAsync(hstring(targetPath.filename().wstring()), CreationCollisionOption::OpenIfExists).get();
- wd::impl::winrt::interfaces::storage::WinRTDirectory* folderRT = new wd::impl::winrt::interfaces::storage::WinRTDirectory(path / targetPath.filename());
+ std::shared_ptr folderRT = std::make_shared(path / targetPath.filename());
return folderRT;
}
catch (const hresult_error& ex) {
diff --git a/vcpkg.json b/vcpkg.json
new file mode 100644
index 0000000..e9bf53e
--- /dev/null
+++ b/vcpkg.json
@@ -0,0 +1,7 @@
+{
+ "name": "windurango",
+ "version": "1.0",
+ "dependencies": [
+ "cppwinrt"
+ ]
+}