diff --git a/include/eepp/system/filesystem.hpp b/include/eepp/system/filesystem.hpp index 99ad35554..ac2681efd 100644 --- a/include/eepp/system/filesystem.hpp +++ b/include/eepp/system/filesystem.hpp @@ -105,6 +105,9 @@ class EE_API FileSystem { /** Removes the current working directory from a path */ static void filePathRemoveCurrentWorkingDirectory(std::string & path); + + /** @return Returns free disk space for a given path in bytes */ + static Int64 getDiskFreeSpace(const std::string& path); }; }} diff --git a/include/eepp/system/sys.hpp b/include/eepp/system/sys.hpp index a5e436b61..2840f56e6 100644 --- a/include/eepp/system/sys.hpp +++ b/include/eepp/system/sys.hpp @@ -40,12 +40,12 @@ class EE_API Sys { /** @return The OS Architecture */ static std::string getOSArchitecture(); + /** @return The platform name. */ + static std::string getPlatform(); + /** @return The Number of CPUs of the system. */ static int getCPUCount(); - /** @return Returns free disk space for a given path in bytes */ - static Int64 getDiskFreeSpace(const std::string& path); - /** Dynamically load a shared object and return a pointer to the object handle. ** @param sofile a system dependent name of the object file ** @return The pointer to the object handle or NULL if there was an error */ diff --git a/src/eepp/system/filesystem.cpp b/src/eepp/system/filesystem.cpp index 1485ad72d..9c4a801e4 100644 --- a/src/eepp/system/filesystem.cpp +++ b/src/eepp/system/filesystem.cpp @@ -26,6 +26,16 @@ #endif #endif +#if defined( EE_PLATFORM_POSIX ) + #if EE_PLATFORM != EE_PLATFORM_ANDROID + #include + #else + #include + #define statvfs statfs + #define fstatvfs fstatfs + #endif +#endif + namespace EE { namespace System { std::string FileSystem::getOSSlash() { @@ -545,4 +555,30 @@ std::string FileSystem::getCurrentWorkingDirectory() { #endif } +Int64 FileSystem::getDiskFreeSpace(const std::string& path) { +#if defined( EE_PLATFORM_POSIX ) + struct statvfs data; + statvfs(path.c_str(), &data); + #if EE_PLATFORM != EE_PLATFORM_MACOSX + return (Int64)data.f_bsize * (Int64)data.f_bfree; + #else + return (Int64)data.f_frsize * (Int64)data.f_bfree; + #endif +#elif EE_PLATFORM == EE_PLATFORM_WIN + Int64 AvailableBytes; + Int64 TotalBytes; + Int64 FreeBytes; + #ifdef UNICODE + GetDiskFreeSpaceEx((LPCWSTR)path.c_str(),(PULARGE_INTEGER) &AvailableBytes, + #else + GetDiskFreeSpaceEx(path.c_str(),(PULARGE_INTEGER) &AvailableBytes, + #endif + (PULARGE_INTEGER) &TotalBytes, (PULARGE_INTEGER) &FreeBytes); + + return FreeBytes; +#else + return -1; +#endif +} + }} diff --git a/src/eepp/system/sys.cpp b/src/eepp/system/sys.cpp index a46c12547..c319b17d3 100644 --- a/src/eepp/system/sys.cpp +++ b/src/eepp/system/sys.cpp @@ -14,14 +14,6 @@ #if defined( EE_PLATFORM_POSIX ) #include #include - - #if EE_PLATFORM != EE_PLATFORM_ANDROID - #include - #else - #include - #define statvfs statfs - #define fstatvfs fstatfs - #endif #endif #if EE_PLATFORM == EE_PLATFORM_MACOSX @@ -337,6 +329,40 @@ std::string Sys::getOSArchitecture() { #endif } +std::string Sys::getPlatform() { +#if EE_PLATFORM == EE_PLATFORM_LINUX + return "Linux"; +#elif EE_PLATFORM == EE_PLATFORM_ANDROID + return "Android"; +#elif EE_PLATFORM == EE_PLATFORM_BSD + #if defined( __FreeBSD__ ) + return "FreeBSD"; + #elif defined(__OpenBSD__) + return "OpenBSD"; + #elif defined( __NetBSD__ ) + return "NetBSD"; + #elif defined( __DragonFly__ ) + return "DragonFlyBSD"; + #else + return "BSD"; + #endif +#elif EE_PLATFORM == EE_PLATFORM_EMSCRIPTEN + return "Emscripten"; +#elif EE_PLATFORM == EE_PLATFORM_HAIKU + return "Haiku"; +#elif EE_PLATFORM == EE_PLATFORM_IOS + return "iOS"; +#elif EE_PLATFORM == EE_PLATFORM_MACOSX + return "macOS"; +#elif EE_PLATFORM == EE_PLATFORM_SOLARIS + return "Solaris"; +#elif EE_PLATFORM_WIN + return "Windows"; +#else + return "Unknown"; +#endif +} + static void eeStartTicks() { static bool TickStarted = false; @@ -706,32 +732,6 @@ int Sys::getCPUCount() { return nprocs; } -Int64 Sys::getDiskFreeSpace(const std::string& path) { -#if defined( EE_PLATFORM_POSIX ) - struct statvfs data; - statvfs(path.c_str(), &data); - #if EE_PLATFORM != EE_PLATFORM_MACOSX - return (Int64)data.f_bsize * (Int64)data.f_bfree; - #else - return (Int64)data.f_frsize * (Int64)data.f_bfree; - #endif -#elif EE_PLATFORM == EE_PLATFORM_WIN - Int64 AvailableBytes; - Int64 TotalBytes; - Int64 FreeBytes; - #ifdef UNICODE - GetDiskFreeSpaceEx((LPCWSTR)path.c_str(),(PULARGE_INTEGER) &AvailableBytes, - #else - GetDiskFreeSpaceEx(path.c_str(),(PULARGE_INTEGER) &AvailableBytes, - #endif - (PULARGE_INTEGER) &TotalBytes, (PULARGE_INTEGER) &FreeBytes); - - return FreeBytes; -#else - return -1; -#endif -} - #if EE_PLATFORM == EE_PLATFORM_WIN int WIN_SetError( std::string prefix = "" ) { TCHAR buffer[1024]; diff --git a/src/eepp/window/window.cpp b/src/eepp/window/window.cpp index 426ab0511..2751dfc79 100644 --- a/src/eepp/window/window.cpp +++ b/src/eepp/window/window.cpp @@ -357,12 +357,13 @@ void Window::sendVideoResizeCb() { void Window::logSuccessfulInit(const std::string& BackendName ) { std::string msg( "Engine Initialized Succesfully.\n\tVersion: " + Version::getVersionName() + " (codename: \"" + Version::getCodename() + "\")" + "\n\tBuild time: " + Version::getBuildTime() + + "\n\tPlatform: " + Sys::getPlatform() + "\n\tOS: " + Sys::getOSName(true) + "\n\tArch: " + Sys::getOSArchitecture() + "\n\tCPU Cores: " + String::toStr( Sys::getCPUCount() ) + "\n\tProcess Path: " + Sys::getProcessPath() + "\n\tCurrent Working Directory: " + FileSystem::getCurrentWorkingDirectory() + - "\n\tDisk Free Space: " + String::toStr( FileSystem::sizeToString( Sys::getDiskFreeSpace( Sys::getProcessPath() ) ) ) + + "\n\tDisk Free Space: " + String::toStr( FileSystem::sizeToString( FileSystem::getDiskFreeSpace( Sys::getProcessPath() ) ) ) + "\n\tWindow/Input Backend: " + BackendName + "\n\tGL Backend: " + GLi->versionStr() + "\n\tGL Vendor: " + GLi->getVendor() +