diff options
author | ouwou <26526779+ouwou@users.noreply.github.com> | 2020-09-30 00:12:38 -0400 |
---|---|---|
committer | ouwou <26526779+ouwou@users.noreply.github.com> | 2020-09-30 00:12:38 -0400 |
commit | 4ac27e91403b708088451c9c07f3b4c2eecb7cf2 (patch) | |
tree | 76c2256ae1786c9c25ee71169bcb5877b5089c2b /util.hpp | |
parent | 1460d891409b019de2a8702b9036c8d2ed602765 (diff) | |
download | abaddon-portaudio-4ac27e91403b708088451c9c07f3b4c2eecb7cf2.tar.gz abaddon-portaudio-4ac27e91403b708088451c9c07f3b4c2eecb7cf2.zip |
add wonky image loading
Diffstat (limited to 'util.hpp')
-rw-r--r-- | util.hpp | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -9,6 +9,36 @@ #include <string> #include <iomanip> +// gtkmm doesnt seem to work +#ifdef _WIN32 + #define WIN32_LEAN_AND_MEAN + #include <Windows.h> + #include <shellapi.h> +#endif + +inline void LaunchBrowser(std::string url) { +#if defined(_WIN32) + // wtf i love the win32 api now ??? + ShellExecuteA(NULL, "open", url.c_str(), NULL, NULL, SW_SHOWNORMAL); +#elif defined(__APPLE__) + std::system(("open " + url).c_str()); +#elif defined(__linux__) + std::system(("xdg-open" + url).c_str()); +#else + printf("can't open url on this platform\n"); +#endif +} + +inline std::string HumanReadableBytes(uint64_t bytes) { + constexpr static const char *x[] = { "B", "KB", "MB", "GB", "TB" }; + int order = 0; + while (bytes >= 1000 && order < 4) { // 4=len(x)-1 + order++; + bytes /= 1000; + } + return std::to_string(bytes) + x[order]; +} + template<typename T> struct Bitwise { static const bool enable = false; |