Exemplo n.º 1
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);
    }
Exemplo n.º 2
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);
    }
Exemplo n.º 3
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);
        }
    }
Exemplo n.º 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");
    }
Exemplo n.º 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);
        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("");
    }
Exemplo n.º 6
0
    private string cd(IGC_URL url)
    {
        IGC_File file = fs.GetFile(url.fullpath);

        if (file != null)
        {
            if (file.isDir)
            {
                if (!fs.CanAccessFile(file, issuer))
                {
                    return("you do not have permission to enter this directory");
                }

                issuer.cwd = file.path;

                if (virtualSystem.networkReady)
                {
                    virtualSystem.GetComponent <NetworkView>().RPC("UpdateCWDRPC", RPCMode.Others, issuer.name, file.path);
                }

                return("");
            }
            else
            {
                return(url.fullpath + " is not a directory");
            }
        }
        return(url.fullpath + " does not exist");
    }
Exemplo n.º 7
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);
    }
Exemplo n.º 8
0
    private string ls(IGC_URL url, bool showHidden, bool asList)
    {
        IGC_File file = fs.GetFile(url.fullpath);

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

            if (file.isDir)
            {
                return(FormatLSString(fs.ListFiles(url, issuer.cwd, showHidden), asList));
            }
            else
            {
                return(file.path + " is not a directory");
            }
        }
        return(url.fullpath + " does not exist");
    }
Exemplo n.º 9
0
    public void OnSystemReady()
    {
        startUpTasksComplete = true;

        //users file
        IGC_File etcUsers = fileSystem.GetFile("/etc/users");

        if (etcUsers == null)
        {
            etcUsers = fileSystem.CreateFile(fileSystem.ParseURL("/etc/users", "/"), userRegistry.rootUser, false);
        }
        etcUsers.data = GetUsersString(SystemStateString());

        //groups file
        IGC_File etcGroups = fileSystem.GetFile("/etc/groups");

        if (etcGroups == null)
        {
            etcGroups = fileSystem.CreateFile(fileSystem.ParseURL("/etc/groups", "/"), userRegistry.rootUser, false);
        }
        etcGroups.data = GetGroupsString(SystemStateString());

        gameObject.GetComponent <InGameComputer>().OnVirtualSystemReady();
    }
Exemplo n.º 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");
    }
Exemplo n.º 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");
    }
Exemplo n.º 12
0
    private string GroupActions()
    {
        if (argv.Length != 5)
        {
            return(malformed_error + "\nusage: file -r|w <add|rm> <groupname> <filename>");
        }

        string action = argv [2];

        if (action != "add" && action != "rm")
        {
            return("action " + argv[2] + " not understood");
        }

        IGC_UserGroup group = registry.GetGroup(argv [3]);

        if (group == null)
        {
            return(argv[3] + " does not exist");
        }

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

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

        bool writeGroup = argv [1] == "-w";

        if (fs.CanAccessFile(file, issuer))
        {
            if (action == "add")
            {
                if (writeGroup)
                {
                    if (file.ApplyEditGroup(group) != null)
                    {
                        return(group.name + " added to " + file.path);
                    }
                    else
                    {
                        return(file.path + " already belongs to " + group.name);
                    }
                }
                else
                {
                    if (file.ApplyAccesGroup(group) != null)
                    {
                        return(group.name + " added to " + file.path);
                    }
                    else
                    {
                        return(file.path + " already belongs to " + group.name);
                    }
                }
            }
            else if (action == "rm")              //redundant, but more legible
            {
                if (writeGroup)
                {
                    if (file.RemoveEditGroup(group))
                    {
                        return(group.name + " removed from " + file.path);
                    }
                    else
                    {
                        return(file.path + " does not belong to " + group.name);
                    }
                }
                else
                {
                    if (file.RemoveAccessGroup(group))
                    {
                        return(group.name + " removed from " + file.path);
                    }
                    else
                    {
                        return(file.path + " does not belong to " + group.name);
                    }
                }
            }
        }

        return("you do not have permission to alter this file");
    }