USER->

newLine(); for (let arg = 0; arg < arguments.length; arg++){ if (arg > 0){ write(arguments[arg]+" ") } } end(); newLine() if (arguments.length > 1){ username = arguments[1].toUpperCase().substring(0,5) startUser = username.toUpperCase()+"@"+curPath+".DIR>" window.localStorage.setItem("NRDOS_username",username.toUpperCase()) write("CHANGED USER") }else{ write(window.localStorage.getItem("NRDOS_username")) } end() clear() currentLine.textContent = startUser if (graphics.style.borderStyle == "none"){ graphics.style.borderStyle = "solid" }else{ graphics.style.borderStyle = "none" } end() newLine() write("BUILT IN COMMANDS") newLine() newLine() write("SAY: REPEATS ALL ARGUMENTS IN CONSOLE | ARGUMENTS ANY") newLine() newLine() write("USER: SHOWS OR CHANGES USERNAME | ARGUMENTS: [USER]") newLine() newLine() write("CLEAR: CLEARS THE SCREEN | ARGUMENTS: NONE") newLine() newLine() write("BORDER: SHOWS BORDER OF SCREEN | ARGUMENTS: NONE") newLine() newLine() write("CD: GOES TO PATH | ARGUMENTS: [/PATH]") newLine() newLine() write("DIR: SHOWS ALL DIRECTORIES AND FILES IN CURRENT DIRECTORY | ARGUMENTS: NONE") newLine() newLine() write("MKDIR: CREATE A NEW DIRECTORY | ARGUMENTS: [NAME]") newLine() newLine() write("MKFILE: CREATE A NEW FILE | ARGUMENTS: [NAME] [EXTENSION (MAX OF 3 CHARACTERS)]") newLine() newLine() end() if (arguments.length > 1){ let dirValid = gotodir(arguments[1]) if (dirValid){ startUser = username+"@"+arguments[1]+">" } }else{ write("INVALID PATH") } end() newLine() newLine() let patharray = curPath.split("/") if (patharray[patharray.length - 1] == ""){ write("DIRECTORY OF ROOT") }else{ write("DIRECTORY OF "+patharray[patharray.length - 1]) } newLine() newLine() Object.getOwnPropertyNames(curDir.dir).forEach(file=>{ write("> "+file+"."+curDir.dir[file].file) newLine() }) end() newLine() if (arguments.length > 1){ let dirname = arguments[1].toLowerCase() let excludedStartChars = ["0","1","2","3","4","5","6","7","8","9"] let alreadycreated = dirname.toLowerCase() in curDir.dir console.log("ALREADY CREATED") console.log(alreadycreated) if (!alreadycreated){ if (!dirname.includes("/") && !dirname.includes(".") && !dirname.includes(" ") && !excludedStartChars.includes(dirname[0]) && !dirname.includes("=")){ curDir.dir[dirname.toLowerCase()] = { file:"dir", dir:{ } } let patharray = curPath.split("/") let curdirname = "ROOT" if (patharray[patharray.length - 1] == ""){ curdirname = "ROOT" }else{ curdirname = patharray[patharray.length - 1] } write("CREATED DIRECTORY '"+dirname.toUpperCase()+".DIR' IN '"+curdirname+"'") }else{ write("INVALID DIRECTORY NAME") } }else{ write("DIRECTORY ALREADY EXISTS") } } end() newLine() let failed = false if (arguments.length > 2){ let filename = arguments[1].toLowerCase() let fileex = arguments[2].toLowerCase() let excludedStartChars = ["0","1","2","3","4","5","6","7","8","9"] let excludedChars = ["/","."," ","="] let errorMsg = "FILE NAME INVALID" for (let char = 0; char < filename.length; char++){ if (excludedChars.includes(filename[char])){ failed = true break } } if (fileex.length > 3 && fileex.toLowerCase() != "dir" && filename.toLowerCase() in curDir.dir){ failed = true } if (filename in curDir.dir){ failed = true errorMsg = "FILE ALREADY EXISTS" } if (!excludedStartChars.includes(filename[0]) && failed == false){ let newFile = { content:"", file:fileex.toLowerCase() } curDir.dir[filename.toLowerCase()] = newFile let patharray = curPath.split("/") let curdirname = "ROOT" if (patharray[patharray.length - 1] == ""){ curdirname = "ROOT" }else{ curdirname = patharray[patharray.length - 1] } write("CREATED FILE '"+filename.toUpperCase()+"."+fileex.toUpperCase()+"' IN DIRECTORY '"+curdirname.toUpperCase()+"'") }else{ failed = true } }else{ failed = true errorMsg = "TOO FEW ARGUMENTS TO CREATE FILE" } if (failed){ write(errorMsg) } end()