-
Notifications
You must be signed in to change notification settings - Fork 3
/
bs.nim
40 lines (34 loc) · 989 Bytes
/
bs.nim
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
import os, strutils, algorithm
type
SupFile = object
name: string
size: int
dylibPath: string
xmlPath: string
proc fileSize(name: string): int =
try:
var f = open(name)
if f == nil: return 0
result = int(getFileSize(f))
f.close()
except:
result = 0
proc cmp(a, b: SupFile): int =
result = cmp(a.size, b.size)
proc main() =
var support = newSeq[SupFile]()
let folder = "/System/Library/Frameworks"
let bsPath = "/Resources/BridgeSupport/"
for x in walkDir(folder):
let pos = rfind(x.path, ".framework")
if pos != -1:
let name = x.path.substr(folder.len+1,pos-1)
let xmlPath = x.path & bsPath & name & ".bridgesupport"
let dylibPath = x.path & bsPath & name & ".dylib"
let size = fileSize(xmlPath)
support.add SupFile(name: name, size: size, dylibPath: dylibPath, xmlPath: xmlPath)
support.sort(cmp)
for x in support:
echo x.size, " ", x.name
echo x.dylibPath
main()