71 lines
1.9 KiB
C++
71 lines
1.9 KiB
C++
#ifndef CC_SysTem_H
|
|
#define CC_SysTem_H
|
|
|
|
#include "basic/CC.h"
|
|
|
|
#ifdef _WIN32
|
|
|
|
#elif __linux__
|
|
|
|
#endif
|
|
|
|
namespace CTL{
|
|
struct MemoryInfo {
|
|
size_t total;
|
|
size_t available;
|
|
};
|
|
enum OS {
|
|
Windows11 = 1,
|
|
Windows10 = 2,
|
|
Windows8 = 3,
|
|
Windows7 = 4,
|
|
WindowsXP = 5,
|
|
WindowsServer = 6,
|
|
Linux = 7,
|
|
OpenHarmony = 0,
|
|
Unknown = -1
|
|
};
|
|
class System{
|
|
public:
|
|
static bool SetAppAutoStart(bool F);
|
|
static bool IsAppAutoStart();
|
|
static CTL::String GetAppName();
|
|
static CTL::String ApplicationDirPath();
|
|
static void Exit(int code = 0);
|
|
static void Execute(const CTL::String& cmd);
|
|
template<typename... Args>
|
|
static void Println(const char* fmt, Args... args);
|
|
static void Println(const CTL::String& str);
|
|
static void ReleaseProcessHeap();
|
|
static unsigned int GetPhysicalCores();
|
|
static unsigned int GetLogicalCores();
|
|
static float GetCPUUsage();
|
|
static MemoryInfo GetMemoryInfo();
|
|
static String GetMac();
|
|
static CTL::String GetOSName();
|
|
static OS GetOS();
|
|
private:
|
|
static OS GetOS(const CTL::String& os);
|
|
#ifdef _WIN32
|
|
inline static void CreateShortO();
|
|
inline static bool DeleteShortO();
|
|
inline static CTL::String OpenKit_Dir = "C:/ProgramData/Microsoft/Windows/Start Menu/Programs/StartUp/";
|
|
#elif __linux__
|
|
static CTL::String GetUserName();
|
|
static bool SetFileReadPermission(const std::string& filePath);
|
|
#endif
|
|
};
|
|
|
|
template<typename ... Args>
|
|
void System::Println(const char *fmt, Args... args) {
|
|
const std::string str = CC::format(fmt,args...);
|
|
#ifdef CC_OHOS_
|
|
OH_LOG_Print(LOG_APP, LOG_INFO, 0x0728, "CC_SDK", "%{public}s",str.c_str());
|
|
#else
|
|
CC::Println(str);
|
|
#endif
|
|
}
|
|
}
|
|
|
|
#endif
|