blob: 4fde82012702d88ccb2126635b388c54f8d6d37f (
plain) (
blame)
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
|
import posix, strutils, os
type
Tstatfs {.importc: "struct statfs64",
header: "<sys/statfs.h>", final, pure.} = object
f_type: int
f_bsize: int
f_blocks: int
f_bfree: int
f_bavail: int
f_files: int
f_ffree: int
f_fsid: int
f_namelen: int
proc statfs(path: string, buf: var Tstatfs): int {.
importc, header: "<sys/vfs.h>".}
proc getSystemVersion*(): string =
result = ""
var unix_info: TUtsname
if uname(unix_info) != 0:
os.OSError()
if $unix_info.sysname == "Linux":
# Linux
result.add("Linux ")
result.add($unix_info.release & " ")
result.add($unix_info.machine)
elif $unix_info.sysname == "Darwin":
# Darwin
result.add("Mac OS X ")
if "10" in $unix_info.release:
result.add("v10.6 Snow Leopard")
elif "9" in $unix_info.release:
result.add("v10.5 Leopard")
elif "8" in $unix_info.release:
result.add("v10.4 Tiger")
elif "7" in $unix_info.release:
result.add("v10.3 Panther")
elif "6" in $unix_info.release:
result.add("v10.2 Jaguar")
elif "1.4" in $unix_info.release:
result.add("v10.1 Puma")
elif "1.3" in $unix_info.release:
result.add("v10.0 Cheetah")
elif "0" in $unix_info.release:
result.add("Server 1.0 Hera")
else:
result.add($unix_info.sysname & " " & $unix_info.release)
when false:
var unix_info: TUtsname
echo(uname(unix_info))
echo(unix_info.sysname)
echo("8" in $unix_info.release)
echo(getSystemVersion())
var stfs: TStatfs
echo(statfs("sysinfo_posix.nim", stfs))
echo(stfs.f_files)
|