-
Notifications
You must be signed in to change notification settings - Fork 0
/
HelperProcess.gd
44 lines (39 loc) · 1.58 KB
/
HelperProcess.gd
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
extends RefCounted
class_name RefHelpers
#This is a class I made for various helper functions that I didn't want sticking
#around in RAM when they were done
var Information:Dictionary
var reposet: bool = false
func BufferToJSON(downloadedbuffer: PackedByteArray):
var raw: String = downloadedbuffer.get_string_from_utf8()
if JSON.parse_string(raw) == null:
OS.alert("There's an issue with the repo.json file, try redownloading it", "repo.json could not be read")
reposet = false
else:
Information = JSON.parse_string(raw)
reposet = true
func JSONToAppInfo():
if not reposet:
return false
var list: int = Information.packages.size()
for items in range(0, list):
var newitem: HBASAppInfo = HBASAppInfo.new()
var infodict: Dictionary = BrewInfo.Information.packages[items]
newitem.InformationFromDictionary(infodict)
BrewInfo.AppInfoArray.append(newitem)
return true
func UnZipBrew(dirin: String, dirout: String):
var zip:ZIPReader = ZIPReader.new()
zip.open(dirin)
for items in zip.get_files():
var itemdir = items.get_base_dir()
print(items)
var extfile:FileAccess = FileAccess.open(BrewInfo.InternalDownloadDir+items.get_file(),FileAccess.WRITE_READ)
var content = zip.read_file(items)
extfile.store_buffer(content)
if not DirAccess.dir_exists_absolute(BrewInfo.InternalDownloadDir+itemdir+"/"):
for folders in items.count("/"):
print(items.get_slice("/", folders))
print("Dir made")
DirAccess.make_dir_absolute(BrewInfo.InternalDownloadDir+items.get_slice("/", folders)+"/")
DirAccess.rename_absolute(BrewInfo.InternalDownloadDir+items.get_file(), items)