-
Notifications
You must be signed in to change notification settings - Fork 0
/
platformHelper.cpp
78 lines (75 loc) · 1.44 KB
/
platformHelper.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include "platformHelper.hpp"
int getPlatform(){//0=linux, 1=windows, 2=osx, 3=bsd
#ifdef _WIN32
return 1;
#elif _WIN64
return 1;
#elif __APPLE__ || __MACH__
return 2;
#elif __linux__
return 0;
#elif __FreeBSD__
return 3;
#endif
return(-1);
}
int getPlatform(std::string& pArg){
if(pArg == "Windows"){
return 1;
}else if(pArg == "windows"){
return 1;
}else if(pArg == "Win"){
return 1;
}else if(pArg == "win"){
return 1;
}else if(pArg == "Linux"){
return 0;
}else if(pArg == "linux"){
return 0;
}else if(pArg == "Macos"){
return 2;
}else if(pArg == "macos"){
return 2;
}else if(pArg == "MacOS"){
return 2;
}else if(pArg == "MacOs"){
return 2;
}else if(pArg == "OSX"){
return 2;
}else if(pArg == "osx"){
return 2;
}else if(pArg == "FreeBSD"){
return 3;
}else if(pArg == "BSD"){
return 3;
}else if(pArg == "bsd"){
return 3;
}else{
if(pArg.length() >= 5 && pArg.substr(0, 5) == "Linux"){
return 0;
}else if(pArg.length() >= 7 && pArg.substr(0, 7) == "Windows"){
return 1;
}else if(pArg.length() >= 5 && pArg.substr(0, 5) == "Macos"){
return 2;
}else if(pArg.length() >= 7 && pArg.substr(0, 7) == "FreeBSD"){
return 3;
}else{
return -1;
}
}
}
std::string getPlatformName(int platform){
switch(platform){
case 0:
return("Linux");
case 1:
return("Windows");
case 2:
return("Macos");
case 3:
return("FreeBSD");
default:
return("");
}
return("");
}