mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-06-04 20:46:29 +03:00
Moved Sys::getDiskFreeSpace to FileSystem::getDiskFreeSpace.
Added Sys::getPlatform. --HG-- branch : dev-2.1
This commit is contained in:
@@ -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);
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -26,6 +26,16 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined( EE_PLATFORM_POSIX )
|
||||
#if EE_PLATFORM != EE_PLATFORM_ANDROID
|
||||
#include <sys/statvfs.h>
|
||||
#else
|
||||
#include <sys/vfs.h>
|
||||
#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
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -14,14 +14,6 @@
|
||||
#if defined( EE_PLATFORM_POSIX )
|
||||
#include <dlfcn.h>
|
||||
#include <sys/utsname.h>
|
||||
|
||||
#if EE_PLATFORM != EE_PLATFORM_ANDROID
|
||||
#include <sys/statvfs.h>
|
||||
#else
|
||||
#include <sys/vfs.h>
|
||||
#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];
|
||||
|
||||
@@ -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() +
|
||||
|
||||
Reference in New Issue
Block a user