/
lock.dm
42 lines (41 loc) · 1.47 KB
/
lock.dm
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
/// Toggles storage devices being read-only
/datum/terminal_command/lock
name = "lock"
man_entry = list(
"Format: lock \[did\]",
"Lists storage devices, or toggle read-only flag on storage device specified by device id.",
"For example, 'lock R' will toggle read-only mode on the device mounted on R:.",
"WARNING: All files on affected device will be read-only, and new files cannot be created."
)
pattern = "^lock"
skill_needed = SKILL_TRAINED
/datum/terminal_command/lock/proper_input_entered(text, mob/user, datum/terminal/terminal)
var/list/arguments = get_arguments(text)
if(isnull(arguments))
return syntax_error()
var/list/drives = list(
"C" = terminal.computer.get_component(PART_HDD),
"R" = terminal.computer.get_component(PART_DRIVE)
)
if(!istype(drives["C"], /obj/item/stock_parts/computer/hard_drive))
return "[name]: Error; hard drive not found."
. = syntax_error()
var/obj/item/stock_parts/computer/hard_drive/D
if(!length(arguments))
. = list()
. += "[name]: Listing storage device status..."
for(var/did in drives)
D = drives[did]
if(!istype(D))
continue
. += ""
. += "** Device mounted on device id [did]: **"
. += D.diagnostics()
else if(length(arguments) == 1)
if(length(arguments[1]) != 1)
return
D = drives[arguments[1]]
if(!istype(D))
return "[name]: Error; invalid device id.";
D.read_only = D.read_only ? FALSE : TRUE
return "[name]: Read-only mode on [arguments[1]] is now [D.read_only ? "enabled" : "disabled"]."