Skip to content
Snippets Groups Projects
Commit 90563cf2 authored by Sebastian Hahta's avatar Sebastian Hahta
Browse files

build uwp

parent 157238e9
No related branches found
No related tags found
No related merge requests found
...@@ -98,7 +98,7 @@ Net::Net(const std::string &uri, ftl::net::Universe *net, bool host) : ...@@ -98,7 +98,7 @@ Net::Net(const std::string &uri, ftl::net::Universe *net, bool host) :
name_.resize(1024); name_.resize(1024);
#ifdef WIN32 #ifdef WIN32
DWORD size = name_.capacity(); DWORD size = name_.capacity();
GetComputerName(name_.data(), &size); GetComputerNameA(name_.data(), &size);
#else #else
gethostname(name_.data(), name_.capacity()); gethostname(name_.data(), name_.capacity());
#endif #endif
......
...@@ -14,15 +14,45 @@ ...@@ -14,15 +14,45 @@
#include <ftl/lib/loguru.hpp> #include <ftl/lib/loguru.hpp>
#include <ftl/exception.hpp> #include <ftl/exception.hpp>
#ifndef WIN32 #if defined(WIN32)
#include <unistd.h>
#else
#include <direct.h> #include <direct.h>
#include <shlwapi.h> #include <shlwapi.h>
#pragma comment(lib, "Shlwapi.lib") #pragma comment(lib, "Shlwapi.lib")
#else
#include <unistd.h>
#endif #endif
#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP)
// UWP/Windows Store app
#include <Windows.h>
char* getcwd(char* buffer, int size) {
return _getcwd(buffer, size);
}
std::string get_home_dir() {
return std::string(); // TODO
}
#else // non-UWP
std::string get_home_dir() {
#if defined(WIN32)
const char* homeDrive = std::getenv("HOMEDRIVE");
const char* homePath = std::getenv("HOMEPATH");
return string((homeDrive) ? homeDrive : "")
+ string((homePath) ? homePath : "");
#else
return std::getenv("HOME");
#endif
}
#endif // UWP
using ftl::URI; using ftl::URI;
using ftl::uri_t; using ftl::uri_t;
using std::string; using std::string;
...@@ -79,20 +109,13 @@ void URI::_parse(uri_t puri) { ...@@ -79,20 +109,13 @@ void URI::_parse(uri_t puri) {
} else if (suri[0] == '/') { } else if (suri[0] == '/') {
suri = std::string("file://") + suri; suri = std::string("file://") + suri;
} else if (suri[0] == '~') { } else if (suri[0] == '~') {
#ifdef WIN32 suri = string("file://") + get_home_dir() + suri.substr(1);
const char *homeDrive = std::getenv("HOMEDRIVE");
const char *homePath = std::getenv("HOMEPATH");
suri = string("file://")
+ string((homeDrive) ? homeDrive : "")
+ string((homePath) ? homePath : "")
+ suri.substr(1);
#else
const char *homeDir = std::getenv("HOME");
suri = string("file://") + string((homeDir) ? homeDir : "") + suri.substr(1);
#endif
} }
#ifdef WIN32 #if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP)
// TODO
#elif defined(WIN32)
if (std::regex_match(puri, std::regex("^[A-Z]:.*"))) { if (std::regex_match(puri, std::regex("^[A-Z]:.*"))) {
suri.resize(1024); suri.resize(1024);
DWORD size = suri.size(); DWORD size = suri.size();
...@@ -210,7 +233,11 @@ std::string URI::toFilePath() const { ...@@ -210,7 +233,11 @@ std::string URI::toFilePath() const {
throw FTL_Error("Not a file URI"); throw FTL_Error("Not a file URI");
} }
#ifdef WIN32 #if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP)
// TODO
return getPath();
#elif defined(WIN32)
std::string result; std::string result;
result.resize(1024); result.resize(1024);
DWORD size = result.size(); DWORD size = result.size();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment