/datum/computer/file/terminal_program/os/main_os/no_login
setup_needs_authentication = 0
/datum/computer/file/terminal_program/os/main_os
name = "ThinkDOS"
size = 12
var/tmp/datum/computer/folder/current_folder = null
var/tmp/datum/computer/file/clipboard = null
var/tmp/datum/computer/file/text/command_log = null
var/tmp/datum/computer/file/record/help_lib = null
var/tmp/datum/computer/file/user_data/active_account = null
var/echo_input = 1
var/log_errors = 1
var/list/peripherals = list()
var/authenticated = null //Is anyone logged in?
var/setup_version_name = "ThinkDOS 0.7.2"
var/setup_needs_authentication = 1 //Do we need to present an ID to use this?
//Setup for data logging
#define SETUP_LOG_DIRECTORY "logs"
#define SETUP_LOG_FILENAME "syslog"
//Setup for help library
#define SETUP_HELP_FILEPATH "/logs/helplib"
//Where to put user account data.
#define SETUP_ACC_DIRECTORY "logs"
#define SETUP_ACC_FILENAME "sysusr"
disposing()
peripherals = null
current_folder = null
clipboard = null
command_log = null
help_lib = null
active_account = null
..()
input_text(text)
if(..())
return
var/list/command_list = parse_string(text)
var/command = command_list[1]
command_list -= command_list[1] //Remove the command we are now processing.
if(src.echo_input)
src.print_text(strip_html(text))
print_to_log(text) //print to log strips html as it logs, no need to do it here!!
if(!current_folder)
current_folder = src.holding_folder
if(!src.authenticated && src.setup_needs_authentication)
switch(lowertext(command))
if("login","logon")
if (issilicon(usr) && !isghostdrone(usr))
src.system_login("AIUSR","Station AI", null, 1)
//src.print_text("Authorization Accepted.
Welcome, AIUSR!
Current Folder: [current_folder.name]")
//src.authenticated = "AI"
//src.print_to_log("LOGIN: AIUSR | \[Station AI]")
else
var/obj/item/peripheral/scanner = find_peripheral("ID_SCANNER")
if(!scanner)
src.print_text("Error: No ID scanner detected.")
return
var/datum/signal/login_result = src.peripheral_command("scan_card", null, "\ref[scanner]")
if(istype(login_result))
system_login(login_result.data["registered"], login_result.data["assignment"], login_result.data["access"])
else if(login_result == "nocard")
src.print_text("Error: No ID card inserted.")
else
src.print_text("Login required. Please use \"login\" command.")
else
switch(lowertext(command))
if("cls", "home") //Clear temp var of master computer3
src.master.temp = null
src.master.temp_add = "Screen cleared.
" //Okay perhaps not entirely clear.
src.master.updateUsrDialog()
if("dir", "catalog", "ls") //Show contents of current folder
src.print_text("Files on [current_folder.holder.title] - Used: \[[src.current_folder.holder.file_used]/[src.current_folder.holder.file_amount]\]")
src.print_text("Current Folder: [current_folder.name]")
var/dir_text = null
for(var/datum/computer/P in current_folder.contents)
if(P == src)
dir_text += "[src.name] - SYSTEM - \[Size: [src.size]]
"
continue
dir_text += "[P.name] - [(istype(P,/datum/computer/folder)) ? "FOLDER" : "[P:extension]"] - \[Size: [P.size]]
"
if(dir_text)
src.print_text(dir_text)
if("cd", "chdir") //Attempts to set current folder to directory arg1
var/dir_string = null
if(command_list.len)
dir_string = jointext(command_list, " ")
else
src.print_text("Syntax: \"cd \[directory string]\" String is relative to current directory.")
return
if(dir_string == "/") //If it is seriously just /, act like the root command
src.current_folder = src.current_folder.holder.root
src.print_text("Current Directory is now [current_folder.name]")
return
var/datum/computer/folder/new_dir = parse_directory(dir_string, src.current_folder)
if(!new_dir || !istype(new_dir))
src.print_error_text("Error: Invalid directory or path.")
return
else
src.current_folder = new_dir
src.print_text("Current Directory is now [new_dir.name]")
if("root") //Sets current folder to root of current drive
if(src.current_folder && src.current_folder.holder.root)
src.current_folder = src.current_folder.holder.root
src.print_text("Current Directory is now [current_folder.name]")
if("run") //Runs /datum/computer/file/terminal_program with name arg1
var/prog_name = null
if(command_list.len)
prog_name = jointext(command_list, " ")
else
src.print_text("Syntax: \"run \[program filepath].\" Path is relative to current directory.")
return
var/datum/computer/file/terminal_program/to_run = src.parse_file_directory(prog_name, current_folder)
if(isnull(to_run) || !istype(to_run) || istype(to_run, /datum/computer/file/terminal_program/os))
src.print_error_text("Error: Invalid file name or type.")
else
src.master.run_program(to_run)
src.master.updateUsrDialog()
return
if("makedir","mkdir") //Creates folder in current directory with name arg1
var/new_folder_name = strip_html(jointext(command_list, " "))
new_folder_name = copytext(new_folder_name, 1, 16)
if(!new_folder_name)
src.print_text("Syntax: \"makedir \[new directory name]\"")
return
if(src.get_computer_datum(new_folder_name, current_folder))
src.print_error_text("Error: Directory name in use.")
return
if(is_name_invalid(new_folder_name))
src.print_error_text("Error: Invalid character in name.")
return
var/datum/computer/F = new /datum/computer/folder
F.name = new_folder_name
if(!current_folder.add_file(F))
src.print_error_text("Error: Unable to create new directory.")
//qdel(F)
F.dispose()
else
src.print_text("New directory created.")
if("rename","ren") //Sets name of file arg1 to arg2
var/to_rename = null
var/new_name = null
if(command_list.len >= 2)
to_rename = command_list[1]
new_name = command_list[2]
new_name = copytext(strip_html(new_name), 1, 16)
if(!to_rename || !new_name)
src.print_text("Syntax: \"rename \[name of target] \[new name]\"")
return
if(is_name_invalid(new_name))
src.print_error_text("Error: Invalid character in name.")
return
var/datum/computer/target = get_computer_datum(to_rename, current_folder)
if(!target || !istype(target))
src.print_error_text("Error: File not found.")
return
var/datum/computer/check_existing = get_computer_datum(new_name, src.current_folder)
if(check_existing && check_existing != target )
src.print_error_text("Error: Name in use.")
return
target.name = new_name
src.print_text("Done.")
if("title") //Set the title var of the current drive.
var/new_name = null
if(command_list.len)
new_name = strip_html(jointext(command_list, " "))
new_name = copytext(new_name, 1, 16)
else
src.print_text("Syntax: \"title \[title name]\" Set name of active drive to given title.")
return
if(src.current_folder.holder && !src.current_folder.holder.read_only)
src.current_folder.holder.title = new_name
src.print_text("Drive title set to [new_name].")
else
src.print_error_text("Error: Unable to set title string.")
if("delete", "del","era","erase","rm") //Deletes file arg1
var/file_name = null
if(command_list.len)
file_name = ckey(jointext(command_list, " "))
else
src.print_text("Syntax: \"del \[file name].\" File must be in current directory.")
return
var/datum/computer/target = get_computer_datum(file_name, current_folder)
if(!target || !istype(target))
src.print_error_text("Error: File not found.")
return
if(target == src)
src.print_error_text("Error: Access denied.")
return
if(src.master.delete_file(target))
src.print_text("File deleted.")
else
src.print_error_text("Error: Unable to delete file.")
if("copy","cp") //Sets file arg1 to be copied
var/file_name = null
if(command_list.len)
file_name = ckey(jointext(command_list, " "))
else
src.print_text("Syntax: \"copy \[file name].\" File must be in current directory.")
return
var/datum/computer/target = get_file_name(file_name, current_folder)
if(!target || !istype(target))
src.print_error_text("Error: File not found.")
return
src.clipboard = target
src.print_text("File marked.")
if("paste","ps") //Pastes clipboard file with name arg1
var/pasted_name = strip_html(jointext(command_list, " "))
pasted_name = copytext(pasted_name, 1, 16)
if(!pasted_name)
src.print_text("Syntax: \"paste \[new file name].\" File is placed in current directory.")
return
if(!src.clipboard || !src.clipboard.holder || !(src.clipboard.holder in src.master.contents))
src.print_error_text("Error: Unable to locate marked file.")
return
if(!istype(src.clipboard))
src.print_error_text("Error: Invalid or corrupt file type.")
return
if(get_computer_datum(pasted_name, src.current_folder))
src.print_error_text("Error: Name in use.")
return
if(is_name_invalid(pasted_name))
src.print_error_text("Error: Invalid character in name.")
return
if(src.clipboard.copy_file_to_folder(current_folder, pasted_name))
src.print_text("Done")
else
src.print_error_text("Error: Unable to paste file (Drive is full?)")
if("drive","drv") //Sets current folder to root of drive arg1
var/argument1 = null
if(command_list.len)
argument1 = command_list[1]
var/list/drives = src.get_loaded_drives()
if(!ckey(argument1))
var/valid_string = english_list(drives, "None", " ")
src.print_text("Syntax: \"drive \[drive id].\"
Valid IDs: ([valid_string]).")
return
var/obj/item/disk/data/to_load = drives[argument1]
if(to_load && istype(to_load) && to_load.root)
src.current_folder = to_load.root
src.print_text("Current Drive is now [current_folder.holder.title]")
else
src.print_text("Error: Drive invalid.")
if("initlogs") //Restart logging if log file is deleted or otherwise lost.
if(src.command_log)
src.print_error_text("Error: Logging is already active.")
else
if(initialize_logs())
src.print_text("Logging re-initialized.")
else
src.print_error_text("Error: Unable to re-initialize logging.")
if("help") //Allow access to "helplib" record datum. Should be kept tup to date with system commands, etc
if(!src.help_lib || !istype(src.help_lib) || help_lib.disposed)
help_lib = null
src.print_error_text("Error: Help file missing or corrupt.")
return
else
var/argument1 = "help"
if(command_list.len)
argument1 = lowertext(command_list[1])
var/help_string = src.help_lib.fields[argument1]
if(help_string)
src.print_text("[capitalize(argument1)]
[help_string]")
else
src.print_error_text("Error: Invalid field.")
if("periph","p") //Allow some user interactions with peripheral cards.
var/argument1 = null
if(command_list.len)
argument1 = command_list[1]
switch(argument1)
if("view","v") //View installed cards.
src.print_text("Current active peripheral cards:")
if(!src.peripherals.len)
src.print_text("