PasswordProtectedFiles (#5067)

This PR adds password protected files. When creating a file an additional prompt will come up. This will ask if you would like to set a password. If left blank a password will not be set and the file will function normally. If a password is set, when viewing, cloning, renaming, or deleting a file, the password prompt will again come up asking for the previously set password. When cloned, the cloned file retains the password.
This commit is contained in:
dapocalypse
2018-09-23 14:38:47 +03:00
committed by Erki
parent 1a6101a842
commit c5f5f8c68d
4 changed files with 91 additions and 4 deletions
@@ -6,7 +6,8 @@ var/global/file_uid = 0
var/size = 1 // File size in GQ. Integers only!
var/obj/item/weapon/computer_hardware/hard_drive/holder // Holder that contains this file.
var/unsendable = 0 // Whether the file may be sent to someone via NTNet transfer or other means.
var/undeletable = 0 // Whether the file may be deleted. Setting to 1 prevents deletion/renaming/etc.
var/undeletable = 0 // Whether the file may be deleted. Setting to 1 prevents deletion/renaming/etc.
var/password = "" // Placeholder for password protected files.
var/uid // UID of this file
/datum/computer_file/New()
@@ -31,9 +32,21 @@ var/global/file_uid = 0
temp.unsendable = unsendable
temp.undeletable = undeletable
temp.size = size
temp.password = password
if(rename)
temp.filename = filename + "(Copy)"
else
temp.filename = filename
temp.filetype = filetype
return temp
/datum/computer_file/proc/can_access_file(var/mob/user, input_password = "")
if(!password)
return TRUE
else
if (!input_password)
input_password = sanitize(input(user, "Please enter a password to access file '[filename]':"))
if (input_password == password)
return TRUE
else
return FALSE