Exemple #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
            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);
    }