Merge pull request #9662 from dapocalypse/PasswordProtectedFiles

Adds password protected files to modular computers.
This commit is contained in:
variableundefined
2018-10-20 11:01:35 +08:00
committed by GitHub
3 changed files with 49 additions and 5 deletions
@@ -55,7 +55,8 @@
"name" = F.filename,
"type" = F.filetype,
"size" = F.size,
"undeletable" = F.undeletable
"undeletable" = F.undeletable,
"encrypted" = !!F.password
)))
data["files"] = files
if(RHDD)
@@ -66,7 +67,8 @@
"name" = F.filename,
"type" = F.filetype,
"size" = F.size,
"undeletable" = F.undeletable
"undeletable" = F.undeletable,
"encrypted" = !!F.password
)))
data["usbfiles"] = usbfiles
@@ -83,6 +85,9 @@
switch(href_list["action"])
if("PRG_openfile")
. = 1
var/datum/computer_file/F = HDD.find_file_by_name(href_list["name"])
if(!F.can_access_file(usr))
return
open_file = href_list["name"]
if("PRG_newtextfile")
. = 1
@@ -197,4 +202,27 @@
if(!F || !istype(F))
return 1
var/datum/computer_file/C = F.clone(0)
HDD.store_file(C)
HDD.store_file(C)
if("PRG_encrypt")
. = 1
if(!HDD)
return 1
var/datum/computer_file/F = HDD.find_file_by_name(href_list["name"])
if(!F || F.undeletable)
return 1
if(F.password)
return
var/new_password = sanitize(input(usr, "Enter an encryption key:", "Encrypt File"))
if(!new_password)
to_chat(usr, "<span class='warning'>File not encrypted.</span>")
return
F.password=new_password
if("PRG_decrypt")
. = 1
if(!HDD)
return 1
var/datum/computer_file/F = HDD.find_file_by_name(href_list["name"])
if(!F || F.undeletable)
return 1
if(F.can_access_file(usr))
F.password = ""