-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.lua
52 lines (45 loc) · 1.37 KB
/
init.lua
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
--- init.lua
--- Author: dousha
--- init.lua is a component of Minecraft ComputerCraft Community Software
--- Distribution (MCCCCSD), licensed under GPLv3.
--- This file is designed to depoly a general file structure like Linux.
---
--- Note: this script is for CraftOS of ComputerCraft, it is NOT compatible
--- with general Lua interpreters.
local rootList = {"home", "lib", "etc"} --> dir.s need to be created
--- home : user directory
--- lib : libraries
--- etc : configurations
local fsMode = {} --> checking result setted by checkFS()
function checkFS() --> void
for i = 1, #(rootList) do
fsMode[rootList[i]] = fs.exists(rootList[i])
end
end
function init() --> bool, but never used
print("This script will deploy a Linux-like file structure")
print("in current working directory.")
print("If you want to install it globally, please run this")
print("file in the root directory.")
print("Press <Enter> to start deployment. Or hold <Ctrl>-<T>")
print("to cancel.")
read()
print("Checking the file system")
if(fs.isReadOnly(".")) then
print("Permission denied.")
print("Please run this script in a WRITEABLE folder")
print("Script will now exit.")
return false
end
checkFS()
for i = 1, #(fsMode) do
if(!fsMode[i]) then
print("Depolying " + rootList[i])
fs.makeDir(rootList[i])
end
end
print("Depolyment success")
return true
end
---- main
init()