コード例 #1
0
ファイル: IGC_Command_mv.cs プロジェクト: XiaoII/Console-2EB
    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);
    }
コード例 #2
0
ファイル: IGC_Command_cp.cs プロジェクト: XiaoII/Console-2EB
    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);
    }
コード例 #3
0
ファイル: IGC_Command_cat.cs プロジェクト: XiaoII/Console-2EB
    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);
        }
    }
コード例 #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
    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");
    }
コード例 #6
0
ファイル: IGC_Command_mv.cs プロジェクト: XiaoII/Console-2EB
    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);
    }
コード例 #7
0
ファイル: IGC_Command_rm.cs プロジェクト: XiaoII/Console-2EB
    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");
    }
コード例 #8
0
ファイル: IGC_Command_ls.cs プロジェクト: XiaoII/Console-2EB
    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");
    }
コード例 #9
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");
    }