Beispiel #1
0
        private void SaveIarCommand(List <string> args, TTY io, UUID limitedToScene)
        {
            if (args[0] == "help")
            {
                string outp = "Available commands:\n";
                outp += "save iar [--noassets] <firstname> <lastname> <inventorypath> <filename>\n";
                io.Write(outp);
                return;
            }

            string firstname     = null;
            string lastname      = null;
            string filename      = null;
            string inventorypath = null;
            var    options       = InventoryArchiver.IAR.SaveOptions.None;

            for (int argi = 2; argi < args.Count; ++argi)
            {
                string arg = args[argi];
                if (arg == "--noassets")
                {
                    options |= InventoryArchiver.IAR.SaveOptions.NoAssets;
                }
                else if (firstname == null)
                {
                    firstname = arg;
                }
                else if (lastname == null)
                {
                    lastname = arg;
                }
                else if (inventorypath == null)
                {
                    inventorypath = arg;
                }
                else
                {
                    filename = arg;
                }
            }

            if (string.IsNullOrEmpty(filename))
            {
                io.Write("missing parameters");
                return;
            }

            UserAccount account;
            UUID        token;

            try
            {
                account = Authenticate(firstname, lastname, io.GetPass("Password"), out token);
            }
            catch (Exception e)
            {
                io.WriteFormatted("failed to authenticate: {0}", e.Message);
                return;
            }

            try
            {
                using (var s = new FileStream(filename, FileMode.Create, FileAccess.Write))
                {
                    InventoryArchiver.IAR.Save(account.Principal, m_InventoryService, m_AssetService, m_AvatarNameServices, options, filename, inventorypath, io);
                }
                io.Write("IAR saved successfully.");
            }
            catch (Exception e)
            {
                io.WriteFormatted("IAR saving failed: {0}", e.Message);
            }
            finally
            {
                m_AuthInfoService.ReleaseToken(account.Principal.ID, token);
            }
        }