示例#1
0
    public override string command_function()
    {
        fs = virtualSystem.fileSystem;
        string targetPath = issuer.cwd;
        bool
            showHidden = false,
            asList     = false;

        if (argv[argv.Length - 1][0] != '-' && argv.Length > 1)
        {
            targetPath = argv[argv.Length - 1];
        }

        foreach (var flag in this.flags)
        {
            if (flag.Key.IndexOf("a") >= 0)
            {
                showHidden = true;
            }
            if (flag.Key.IndexOf("l") >= 0)
            {
                asList = true;
            }
        }

        return(ls(fs.ParseURL(targetPath, issuer.cwd), showHidden, asList));
    }
示例#2
0
    public override string command_function()
    {
        IGC_FileSystem fs = virtualSystem.fileSystem;

        if (argv.Length > 1)
        {
            IGC_URL url = fs.ParseURL(argv[1], issuer.cwd);

            IGC_File file = fs.GetFile(url.fullpath);

            if (file != null)
            {
                if (!fs.CanAccessFile(file, issuer))
                {
                    return("You do not have permission to view this file");
                }

                return(file.data);
            }
            else
            {
                return("file " + url.fullpath + " does not exist");
            }
        }
        else
        {
            return(malformed_error + "\n" + this.usage);
        }
    }
示例#3
0
    public override string command_function()
    {
        if (argv.Length != 2)
        {
            return(malformed_error + "\n" + usage);
        }

        IGC_FileSystem fs = virtualSystem.fileSystem;

        IGC_URL  url  = fs.ParseURL(argv [1], issuer.cwd);
        IGC_File file = fs.GetFile(url.fullpath);

        if (file == null)
        {
            return(url.fullpath + " does not exits");
        }

        if (!fs.CanEditFile(file, issuer))
        {
            return("you do not have permission to edit this file");
        }

        issuer.terminal.shell.EnterEditMode(file);
        return("");
    }
示例#4
0
    public override string command_function()
    {
        if (argv.Length < 2)
        {
            return(malformed_error + "\n" + usage);
        }

        IGC_FileSystem fs  = virtualSystem.fileSystem;
        IGC_URL        url = fs.ParseURL(argv [1], issuer.cwd);

        if (!fs.CanAccessFile(fs.GetFile(url.dirpath), issuer))
        {
            return("you do not have permission to create files in that location");
        }

        if (!fs.FileExists(url.fullpath))
        {
            IGC_File dir = fs.CreateFile(url, issuer, true);
            if (dir != null)
            {
                return("directory " + url.fullpath + " created successfully");
            }
            else
            {
                return("error: broken path");
            }
        }
        return(url.fullpath + " already exists");
    }
示例#5
0
    public override string command_function()
    {
        if (argv.Length < 2)
        {
            return(malformed_error + "\n" + usage);
        }

        IGC_FileSystem fs  = virtualSystem.fileSystem;
        IGC_URL        url = fs.ParseURL(argv [1], issuer.cwd);

        if (!fs.FileExists(url.fullpath))
        {
            IGC_File file = fs.CreateFile(url, issuer, false);

            if (file != null)
            {
                return("file " + file.path + " created successfully");
            }
            else
            {
                return("error: insufficient privilages or broken path");
            }
        }
        return(url.fullpath + " already exists");
    }
示例#6
0
    public override string command_function()
    {
        if (argv.Length != 3)
        {
            return(this.malformed_error + "\n" + this.usage);
        }

        IGC_FileSystem fs = virtualSystem.fileSystem;



        IGC_URL
            oldURL = fs.ParseURL(argv[1], issuer.cwd),
            newURL = fs.ParseURL(argv[2], issuer.cwd);

        if (!fs.FileExists(oldURL.fullpath))
        {
            return("cant move " + argv[1] + " because it doesn't exist");
        }
        Debug.Log("from " + oldURL.fullpath);
        if (!fs.FileExists(newURL.dirpath))
        {
            return("cant move " + argv[1] + " to " + newURL.dirname + " because that directory does not exist.");
        }
        Debug.Log("to " + newURL.dirpath);
        if (fs.FileExists(newURL.fullpath))
        {
            return("new path " + argv[2] + " already exists - have you added the file name to the path?");
        }
        Debug.Log("to fullpath " + newURL.fullpath);

        IGC_File file = fs.GetFile(oldURL.fullpath);
        IGC_File dir  = fs.GetFile(newURL.dirpath);

        if (!fs.CanAccessFile(file, issuer))
        {
            return("you do not have permission to edit " + oldURL.fullpath);
        }
        if (!fs.CanAccessFile(dir, issuer))
        {
            return("you do not have permission to access " + newURL.dirname);
        }

        if (argv[2] == "SVR-01")
        {
        }
        //if svr get gameobject tagged playerserver - move the file from current gameobject to the playerserver gameobject
        //new move file method in FS required, one that takes gameobjects - convert this to extract command?
        fs.MoveFile(oldURL, newURL);

        if (virtualSystem.networkReady)
        {
            fs.GetComponent <NetworkView>().RPC("MoveFileRPC", RPCMode.Others, oldURL.fullpath, newURL.fullpath);
        }

        return(oldURL.filename + " changed to " + newURL.fullpath);
    }
示例#7
0
    public override string command_function()
    {
        fs = virtualSystem.fileSystem;

        if (argv.Length > 1)
        {
            return(cd(fs.ParseURL(argv[1], issuer.cwd)));
        }
        else
        {
            return(cd(fs.ParseURL(issuer.homedir, issuer.cwd)));
        }
    }
示例#8
0
    public override string command_function()
    {
        if (argv.Length != 3)
        {
            return(this.malformed_error + "\n" + this.usage);
        }

        IGC_FileSystem fs = virtualSystem.fileSystem;

        IGC_URL
            target = fs.ParseURL(argv[1], issuer.cwd),
            copy   = fs.ParseURL(argv[2], issuer.cwd);

        if (!fs.FileExists(target.fullpath))
        {
            return("cant copy " + target.fullpath + " because it doesn't exist");
        }
        if (!fs.FileExists(copy.dirpath))
        {
            return("cant copy " + target.filename + " to " + copy.dirname + " because that directory does not exist.");
        }
        if (fs.FileExists(copy.fullpath))
        {
            return(copy.fullpath + " already exists");
        }

        IGC_File file = fs.GetFile(target.fullpath);
        IGC_File dir  = fs.GetFile(copy.dirpath);

        if (!fs.CanAccessFile(file, issuer))
        {
            return("you do not have permission to copy " + target.fullpath);
        }
        if (!fs.CanAccessFile(dir, issuer))
        {
            return("you do not have permission to access " + copy.dirname);
        }


        fs.CopyFile(target, copy);

        if (virtualSystem.networkReady)
        {
            fs.GetComponent <NetworkView>().RPC("CopyFileRPC", RPCMode.Others, target.fullpath, copy.fullpath);
        }

        return(target.filename + " copied to " + copy.fullpath);
    }
示例#9
0
    public override string command_function()
    {
        if (argv.Length != 3)
        {
            return(this.malformed_error + "\n" + this.usage);
        }

        IGC_FileSystem fs = virtualSystem.fileSystem;

        IGC_URL
            oldURL = fs.ParseURL(argv[1], issuer.cwd),
            newURL = fs.ParseURL(argv[2], issuer.cwd);

        if (!fs.FileExists(oldURL.fullpath))
        {
            return("cant move " + argv[1] + " because it doesn't exist");
        }
        if (!fs.FileExists(newURL.dirpath))
        {
            return("cant move " + argv[1] + " to " + newURL.dirname + " because that directory does not exist.");
        }
        if (fs.FileExists(newURL.fullpath))
        {
            return("new path " + argv[2] + " already exists");
        }

        IGC_File file = fs.GetFile(oldURL.fullpath);
        IGC_File dir  = fs.GetFile(newURL.dirpath);

        if (!fs.CanAccessFile(file, issuer))
        {
            return("you do not have permission to edit " + oldURL.fullpath);
        }
        if (!fs.CanAccessFile(dir, issuer))
        {
            return("you do not have permission to access " + newURL.dirname);
        }

        fs.MoveFile(oldURL, newURL);

        if (virtualSystem.networkReady)
        {
            fs.GetComponent <NetworkView>().RPC("MoveFileRPC", RPCMode.Others, oldURL.fullpath, newURL.fullpath);
        }

        return(oldURL.filename + " changed to " + newURL.fullpath);
    }
示例#10
0
    public override string command_function()
    {
        if (argv.Length != 2)
        {
            return(malformed_error + "\n" + usage);
        }

        IGC_FileSystem fs   = virtualSystem.fileSystem;
        IGC_URL        url  = fs.ParseURL(argv [1], issuer.cwd);
        IGC_File       file = fs.GetFile(url.fullpath);

        if (file == null)
        {
            return("input file does not exist");
        }

        Transform platforms = GameObject.Find("room/platforms").transform;

        string[] bridgeFormationData = IGC_Utils.SplitString(",", file.data);

        if (bridgeFormationData.Length != 10)
        {
            return("incorrect number of comma seporated numbers in input file. must be 10.");
        }

        int i = 0;

        foreach (string s in bridgeFormationData)
        {
            int       num = int.Parse(s.Trim());
            Transform t   = platforms.Find(i.ToString());

            t.GetComponent <BridgeSegment>().SetTargetPosition(new Vector3(
                                                                   t.transform.localPosition.x,
                                                                   num,
                                                                   t.transform.localPosition.z
                                                                   ));

            i++;
        }

        return("bridge formation reset");
    }
示例#11
0
    public override string command_function()
    {
        if (argv.Length < 2)
        {
            return(malformed_error + "\n" + usage);
        }

        IGC_FileSystem fs   = virtualSystem.fileSystem;
        IGC_URL        url  = fs.ParseURL(argv [1], issuer.cwd);
        IGC_File       file = fs.GetFile(url.fullpath);


        if (file != null)
        {
            if (!fs.CanAccessFile(file, issuer))
            {
                return("you do not have permission to delete " + file.path);
            }

            if (file.isDir && argv.Length < 3)
            {
                return("you must type '-r' after the folder name to delete a folder and all files/folders within");
            }

            if (!file.isDir || (file.isDir && argv[2] == "-r"))
            {
                if (fs.RMFile(url, issuer))
                {
                    return(url.fullpath + " deleted");
                }
                else
                {
                    return("system error. could not delete file...?");
                }
            }
            else
            {
                return(malformed_error + usage);
            }
        }
        return(url.fullpath + " does not exist");
    }
示例#12
0
    public override string command_function()
    {
        registry = virtualSystem.userRegistry;
        fs       = virtualSystem.fileSystem;

        if (argv.Length > 1)
        {
            keyword = argv[1];
            switch (keyword)
            {
            case "-w": return(GroupActions());

            case "-r": return(GroupActions());

            case "-p": return(ProtectedYN());;

            default: return(FileInfo());
            }
        }

        return(malformed_error + "\nusage: file -<g|p> ...");
    }
示例#13
0
    void Awake()
    {
        GenerateUniqueID();

        if (IP == "")
        {
            GenerateIP();
        }
        else
        {
            hasPermanentIP = true;
        }

        if (eraseSaveDataOnStart || !hasPermanentIP)
        {
            EraseSaveData();
            gameObject.GetComponent <InGameComputer>().EraseSaveData();
        }

        terminal     = gameObject.GetComponent <InGameComputer> ();
        userRegistry = gameObject.GetComponent <IGC_UserRegistry> ();
        fileSystem   = gameObject.GetComponent <IGC_FileSystem> ();
    }
示例#14
0
    public override string command_function()
    {
        //terminal
        string termOutput = "___TERMINAL___\n";

        InGameComputer igc = issuer.terminal;

        termOutput += "instance id: " + igc.instanceID + "\n";
        termOutput += "current power state: " + igc.powerState + "\n";
        termOutput += "login name/pass: "******"/" + issuer.terminal.loginPass + "\n";
        termOutput += "start in on state: " + igc.startInOnState + "\n";
        termOutput += "current user: "******"null") + "\n";
        termOutput += "bounce back user: "******"null") + "\n";
        termOutput += "remote login: "******"\n";
        termOutput += "in use: " + igc.inUse + "\n";
        termOutput += "terminal occupied: " + igc.terminalOccupied + "\n";
        termOutput += "booting up: " + igc.bootingUp + "\n";
        termOutput += "network ready: " + igc.networkReady + "\n";

        //shell
        string shellOutput = "___SHELL___\n";

        IGC_Shell sh = issuer.terminal.shell;

        shellOutput += "display width/height: " + sh.displayWidth + "/" + sh.displayHeight + "\n";
        shellOutput += "prompt width: " + sh.promptWidth + "\n";
        shellOutput += "language: " + sh.lang.LangName + "\n";
        shellOutput += "terminal id: " + sh.computer.instanceID + "\n";
        shellOutput += "input mode: " + sh.inputMode + "\n";
        shellOutput += "capslock: " + sh.capslock + "\n";
        shellOutput += "ctrl: " + sh.ctrl + "\n";
        shellOutput += "history count: " + sh.history.Count + "\n";
        shellOutput += "cursor offset x/y: " + sh.cursorOffset + "/" + sh.cursorOffsetVertical + "\n";
        shellOutput += "display line offset: " + sh.lineOffset + "\n";
        shellOutput += "last edited: " + (sh.lastEditedFile != null ? sh.lastEditedFile.path : "null") + "\n";
        shellOutput += "raw edit string len: " + sh.rawEditString.Length + "\n";
        shellOutput += "raw display text len: " + sh.rawDisplayText.Length + "\n";
        shellOutput += "formatted display len: " + sh.output.text.Length + "\n";
        shellOutput += "raw prompt text len: " + sh.rawPromptText.Length + "\n";
        shellOutput += "formatted prompt len: " + sh.prompt.text.Length + "\n";
        shellOutput += "infoline len: " + sh.infoLine.text.Length + "\n";


        //virtual system
        string vsOutput = "___VIRTUAL SYSTEM___\n";

        IGC_VirtualSystem vs = virtualSystem;

        vsOutput += "instance id: " + vs.instanceID + "\n";
        vsOutput += "model name: " + vs.modelName + "\n";
        vsOutput += "ip: " + vs.IP + "\n";
        vsOutput += "permanent ip: " + vs.hasPermanentIP + "\n";
        vsOutput += "language: " + vs.language.LangName + "\n";
        vsOutput += "startup stasks complete: " + vs.startUpTasksComplete + "\n";
        vsOutput += "network ready: " + vs.networkReady + "\n";
        vsOutput += "erase save data on start: " + vs.eraseSaveDataOnStart + "\n";
        vsOutput += "resore data len: " + vs.restoreData.Length + "\n";

        //userregistry
        string urOutput = "___USER REGISTRY___\n";

        IGC_UserRegistry ur = virtualSystem.userRegistry;

        urOutput += "virtual system id: " + ur.virtualSystem.instanceID + "\n";
        urOutput += "ready for use: " + ur.ready + "\n";
        urOutput += "users logged in: " + ur.loggedInUsers.Count + "\n";
        urOutput += "users: " + ur.users.Count + "\n";
        urOutput += "groups: " + ur.groups.Count + "\n";
        urOutput += "users editor string: \n" + string.Join("\n", ur.usersList) + "\n";
        urOutput += "groups editor string: \n" + string.Join("\n", ur.groupsList) + "\n";

        //file system
        string fsOutput = "___FILE SYSTEM___\n";

        IGC_FileSystem fs = virtualSystem.fileSystem;

        fsOutput += "virtual system id: " + fs.virtualSystem.instanceID + "\n";
        fsOutput += "ready for use: " + fs.ready + "\n";
        fsOutput += "files: " + fs.files.Count + "\n";
        fsOutput += "root node: " + fs.rootNode.name + "\n";

        //unique game instance id
        string gameID = "unique game instance id: " + IGC_VirtualSystem.uniqueID + "\n";

        string output = "";

        if (flags.Count > 0)
        {
            foreach (var k in flags.Keys)
            {
                if (k == "g")
                {
                    output = gameID;
                }
                if (k == "t")
                {
                    output = termOutput;
                }
                if (k == "s")
                {
                    output = shellOutput;
                }
                if (k == "vs")
                {
                    output = vsOutput;
                }
                if (k == "fs")
                {
                    output = fsOutput;
                }
                if (k == "ur")
                {
                    output = urOutput;
                }
            }
            if (output == "")
            {
                return("flag(s) not recognised");
            }
        }
        else
        {
            output = gameID + termOutput + shellOutput + vsOutput + urOutput + fsOutput;
        }

        issuer.terminal.shell.EnterViewMode(output);

        return("");
    }