ExperimentalGear/scripts/core/os.lua

48 lines
797 B
Lua
Raw Normal View History

---@enum Platform
Platform = {
WINDOWS = 0,
LINUX = 1,
MACOS = 2,
UNKNOWN = 3
}
function os.platform()
return Platform.UNKNOWN
end
function os.name()
return "Unknown"
end
---@note setup code from: https://stackoverflow.com/a/30960054
local binary_format = package.cpath:match("%p[\\|/]?%p(%a+)")
if binary_format == "dll" then
function os.platform()
return Platform.WINDOWS
end
function os.name()
return "Windows"
end
elseif binary_format == "so" then
function os.platform()
return Platform.LINUX
end
function os.name()
return "Linux"
end
elseif binary_format == "dylib" then
function os.platform()
return Platform.MACOS
end
function os.name()
return "MacOS"
end
end