This repository was archived by the owner on Dec 21, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstaller_maker.lua
More file actions
67 lines (64 loc) · 1.66 KB
/
installer_maker.lua
File metadata and controls
67 lines (64 loc) · 1.66 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
local function readDirectory(path)
local list = fs.list(path);
local result = {};
for i = 1, #list do
if (list[i] ~= 'Logs' and list[i] ~= 'Temp') then
local data = {};
data.Name = list[i];
data.IsDir = fs.isDir(path..'/'..list[i]);
if (data.IsDir) then
data.Content = readDirectory(path..'/'..list[i]..'/');
end
table.insert(result, data);
end
sleep(0.01);
end
return result;
end
local function printDirectory(data, spacer)
for i = 1, #data do
print(spacer..data[i].Name);
if (data[i].IsDir) then
printDirectory(data[i].Content, spacer..'-');
end
sleep(0.01);
end
end
local function writeDirectories(data, spacer, file)
for i = 1, #data do
file.writeLine(spacer..'{');
file.writeLine(spacer..'\tName = "'..data[i].Name..'",');
if (data[i].IsDir) then
file.writeLine(spacer..'\tIsDir = true,');
file.writeLine(spacer..'\tContent = {');
writeDirectories(data[i].Content, spacer..'\t\t', file);
file.writeLine(spacer..'\t}');
else
file.writeLine(spacer..'\tIsDir = false');
end
if (i == #data) then
file.writeLine(spacer..'}');
else
file.writeLine(spacer..'},');
end
sleep(0.01);
end
end
print('Enter working path:');
local workPath = read();
print('Enter version:');
local version = read();
print('Reading files and directories...');
local data = readDirectory(workPath);
print('Reading finished.');
print('Directory tree:');
printDirectory(data, '');
print('Writing to file...');
local file = fs.open('/tree.lua', 'w');
file.writeLine('version = "'..version..'";');
file.writeLine();
file.writeLine('tree = {');
writeDirectories(data, '\t', file);
file.writeLine('};');
file.close();
print('Finished writing.');