Repository navigation
Expand file tree
/
Copy pathuninstall.ring
More file actions
91 lines (85 loc) · 2.56 KB
/
Copy pathuninstall.ring
File metadata and controls
91 lines (85 loc) · 2.56 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
# Removes the files that setup.ring extracted: the big folders at once, the other files from the list
func main
? "Removing the RingJava package"
cDir = CurrentDir()
chdir(exefolder() + "../")
cList = "extensions/ringjava/package-files.txt"
aFiles = []
if not fexists(cList)
? "RingJava: the list of the files (" + cList + ") was not found: the package is removed already, or it is not installed"
ok
if fexists(cList)
aFiles = str2list(read(cList))
for cFile in aFiles
if cFile != "" and not startsWith(cFile,"libraries/javalib/") and not startsWith(cFile,"samples/UsingJava/") and not startsWith(cFile,"extensions/ringjava/")
remove(cFile)
ok
next
ok
if not isWindows()
remove("lib/ringjava.jar")
remove("lib/paramnames.txt")
remove("lib/libring_java.so")
remove("lib/libring_java.dylib")
ok
# the Java runtime made by tools/javatools/makeruntime.ring
OSDeleteFolder("bin/jre")
OSDeleteFolder("libraries/javalib")
OSDeleteFolder("samples/UsingJava")
OSDeleteFolder("extensions/ringjava")
OSDeleteFolder("tools/javatools")
# the folders that the package made and that are empty now; a folder that still has files stays
aLoop33 = emptyFolders(aFiles)
for cFolder in aLoop33
OSDeleteEmptyFolder(cFolder)
next
chdir(cDir)
func startsWith cText, cStart
return left(cText,len(cStart)) = cStart
# the folders of the listed files, the deepest first (the top folders bin, libraries, samples, tools and extensions are the Ring folders)
func emptyFolders aFiles
aFolders = []
for cFile in aFiles
cFolder = cFile
while substr(cFolder,"/") > 0
cFolder = left(cFolder,len(cFolder) - len(lastPart(cFolder)) - 1)
if substr(cFolder,"/") > 0 and find(aFolders,cFolder) = 0
aFolders + cFolder
ok
end
next
aSorted = []
for cFolder in aFolders
aSorted + [len(cFolder),cFolder]
next
aSorted = sort(aSorted,1)
aResult = []
for nPos = len(aSorted) to 1 step -1
aResult + aSorted[nPos][2]
next
return aResult
func lastPart cPath
nPos = len(cPath)
while nPos > 0 and cPath[nPos] != "/"
nPos--
end
return right(cPath,len(cPath) - nPos)
# removes the folder only when it is empty (rd and rmdir without the option for contents)
func OSDeleteEmptyFolder cFolder
if isWindows()
systemSilent("rd " + substr(cFolder,"/","\") + " 2>nul")
else
systemSilent("rmdir " + cFolder + " 2>/dev/null")
ok
func OSDeleteFolder cFolder
if isWindows()
systemSilent("rd /s /q " + substr(cFolder,"/","\"))
else
systemSilent("rm -r " + cFolder)
ok
func SystemSilent cCmd
if isWindows()
system(cCmd + " >nul 2>nul")
else
system(cCmd + " > /dev/null")
ok