GetContents() 공개 메소드

public GetContents ( InventoryFolder folder ) : List
folder InventoryFolder
리턴 List
예제 #1
0
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            if (args.Length > 1)
            {
                return(ShowUsage()); // " ls [-l]";
            }
            bool longDisplay = false;

            if (args.Length > 0 && args[0] == "-l")
            {
                longDisplay = true;
            }

            Manager   = Client.Inventory;
            Inventory = Manager.Store;
            // WARNING: Uses local copy of inventory contents, need to download them first.
            List <InventoryBase> contents = Inventory.GetContents(TheBotClient.CurrentDirectory);
            string displayString          = "";
            string nl = "\n"; // New line character

            // Pretty simple, just print out the contents.
            foreach (InventoryBase b in contents)
            {
                if (longDisplay)
                {
                    // Generate a nicely formatted description of the item.
                    // It kinda looks like the WriteLine of the unix ls.
                    // starts with 'd' if the inventory is a folder, '-' if not.
                    // 9 character permissions string
                    // UUID of object
                    // Name of object
                    if (b is InventoryFolder)
                    {
                        InventoryFolder folder = b as InventoryFolder;
                        displayString += "d--------- ";
                        displayString += folder.UUID;
                        displayString += " " + folder.Name;
                    }
                    else if (b is InventoryItem)
                    {
                        InventoryItem item = b as InventoryItem;
                        displayString += "-";
                        displayString += PermMaskString(item.Permissions.OwnerMask);
                        displayString += PermMaskString(item.Permissions.GroupMask);
                        displayString += PermMaskString(item.Permissions.EveryoneMask);
                        displayString += " " + item.UUID;
                        displayString += " " + item.Name;
                        displayString += nl;
                        displayString += "  AssetID: " + item.AssetUUID;
                    }
                }
                else
                {
                    displayString += b.Name;
                }
                displayString += nl;
            }
            return(Success(displayString));
        }
예제 #2
0
        public override string Execute(string[] args, UUID fromAgentID)
        {
            if (args.Length > 1)
                return "Usage: ls [-l]";
            bool longDisplay = false;
            if (args.Length > 0 && args[0] == "-l")
                longDisplay = true;

            Manager = Client.Inventory;
            Inventory = Manager.Store;
            // WARNING: Uses local copy of inventory contents, need to download them first.
            List<InventoryBase> contents = Inventory.GetContents(Client.CurrentDirectory);
            string displayString = "";
            string nl = "\n"; // New line character
            // Pretty simple, just print out the contents.
            foreach (InventoryBase b in contents)
            {
                if (longDisplay)
                {
                    // Generate a nicely formatted description of the item.
                    // It kinda looks like the output of the unix ls.
                    // starts with 'd' if the inventory is a folder, '-' if not.
                    // 9 character permissions string
                    // UUID of object
                    // Name of object
                    if (b is InventoryFolder)
                    {
                        InventoryFolder folder = b as InventoryFolder;
                        displayString += "d--------- ";
                        displayString += folder.UUID;
                        displayString += " " + folder.Name;
                    }
                    else if (b is InventoryItem)
                    {
                        InventoryItem item = b as InventoryItem;
                        displayString += "-";
                        displayString += PermMaskString(item.Permissions.OwnerMask);
                        displayString += PermMaskString(item.Permissions.GroupMask);
                        displayString += PermMaskString(item.Permissions.EveryoneMask);
                        displayString += " " + item.UUID;
                        displayString += " " + item.Name;
                        displayString += nl;
                        displayString += "  AssetID: " + item.AssetUUID;
                    }
                }
                else
                {
                    displayString += b.Name;
                }
                displayString += nl;
            }
            return displayString;
        }
예제 #3
0
        void PerformRecursiveSearch(int level, UUID folderID)
        {
            var me     = Inventory.Items[folderID].Data;
            var sorted = Inventory.GetContents(folderID);

            sorted.Sort((InventoryBase b1, InventoryBase b2) =>
            {
                if (b1 is InventoryFolder && !(b2 is InventoryFolder))
                {
                    return(-1);
                }
                else if (!(b1 is InventoryFolder) && b2 is InventoryFolder)
                {
                    return(1);
                }
                else
                {
                    return(string.Compare(b1.Name, b2.Name));
                }
            });

            foreach (var item in sorted)
            {
                if (item is InventoryFolder)
                {
                    PerformRecursiveSearch(level + 1, item.UUID);
                }
                else
                {
                    var it = item as InventoryItem;

                    if (it.UUID.ToString().Contains(searchString))
                    {
                        searchRes.Add(it);
                    }
                }
            }
        }
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            Manager = Client.Inventory;
            Inventory = Client.Inventory.Store;

            if (args.Length > 1)
                return ShowUsage(); // " cd [path-to-folder]";
            string pathStr = "";
            string[] path = null;
            if (args.Length == 0)
            {
                path = new string[] {""};
                // cd without any arguments doesn't do anything.
            }
            else if (args.Length == 1)
            {
                pathStr = args[0];
                path = pathStr.Split(new char[] {'/'});
                // Use '/' as a path seperator.
            }
            InventoryFolder currentFolder = Client.CurrentDirectory;
            if (pathStr.StartsWith("/"))
                currentFolder = Inventory.RootFolder;

            if (currentFolder == null) // We need this to be set to something. 
                return Failure("Error: Client not logged in.");

            // Traverse the path, looking for the 
            for (int i = 0; i < path.Length; ++i)
            {
                string nextName = path[i];
                if (string.IsNullOrEmpty(nextName) || nextName == ".")
                    continue; // Ignore '.' and blanks, stay in the current directory.
                if (nextName == ".." && currentFolder != Inventory.RootFolder)
                {
                    // If we encounter .., move to the Client folder.
                    currentFolder = Inventory[currentFolder.ParentUUID] as InventoryFolder;
                }
                else
                {
                    List<InventoryBase> currentContents = Inventory.GetContents(currentFolder);
                    // Try and find an InventoryBase with the corresponding name.
                    bool found = false;
                    foreach (InventoryBase item in currentContents)
                    {
                        // Allow lookup by UUID as well as name:
                        if (item.Name == nextName || item.UUID.ToString() == nextName)
                        {
                            found = true;
                            if (item is InventoryFolder)
                            {
                                currentFolder = item as InventoryFolder;
                            }
                            else
                            {
                                return Failure(item.Name + " is not a folder.");
                            }
                        }
                    }
                    if (!found)
                        return Failure(nextName + " not found in " + currentFolder.Name);
                }
            }
            Client.CurrentDirectory = currentFolder;
            return Success("Current folder: " + currentFolder.Name);
        }
예제 #5
0
        public override string Execute(string[] args, UUID fromAgentID)
        {
            Inventory = Client.Inventory.Store;

            if (args.Length > 1)
            {
                return("Usage: cd [path-to-folder]");
            }
            string pathStr = "";

            string[] path = null;
            if (args.Length == 0)
            {
                path = new string[] { "" };
                // cd without any arguments doesn't do anything.
            }
            else if (args.Length == 1)
            {
                pathStr = args[0];
                path    = pathStr.Split(new char[] { '/' });
                // Use '/' as a path seperator.
            }
            InventoryFolder currentFolder = Client.CurrentDirectory;

            if (pathStr.StartsWith("/"))
            {
                currentFolder = Inventory.RootFolder;
            }

            if (currentFolder == null) // We need this to be set to something.
            {
                return("Error: Client not logged in.");
            }

            // Traverse the path, looking for the
            for (int i = 0; i < path.Length; ++i)
            {
                string nextName = path[i];
                if (string.IsNullOrEmpty(nextName) || nextName == ".")
                {
                    continue; // Ignore '.' and blanks, stay in the current directory.
                }
                if (nextName == ".." && currentFolder != Inventory.RootFolder)
                {
                    // If we encounter .., move to the parent folder.
                    currentFolder = Inventory[currentFolder.ParentUUID] as InventoryFolder;
                }
                else
                {
                    List <InventoryBase> currentContents = Inventory.GetContents(currentFolder);
                    // Try and find an InventoryBase with the corresponding name.
                    bool found = false;
                    foreach (InventoryBase item in currentContents)
                    {
                        // Allow lookup by UUID as well as name:
                        if (item.Name == nextName || item.UUID.ToString() == nextName)
                        {
                            found = true;
                            if (item is InventoryFolder)
                            {
                                currentFolder = item as InventoryFolder;
                            }
                            else
                            {
                                return(item.Name + " is not a folder.");
                            }
                        }
                    }
                    if (!found)
                    {
                        return(nextName + " not found in " + currentFolder.Name);
                    }
                }
            }
            Client.CurrentDirectory = currentFolder;
            return("Current folder: " + currentFolder.Name);
        }
예제 #6
0
파일: Tools.cs 프로젝트: jvanveen/ppt2os
 //Finds our ppt2os basefolder, or creates one if not existing yet
 private UUID find_ppt2os_folder(GridClient client)
 {
     Manager = client.Inventory;
     Inventory = Manager.Store;
     InventoryFolder rootFolder = Inventory.RootFolder;
     UUID texture_basefolder = client.Inventory.FindFolderForType(AssetType.Texture);
     List<InventoryBase> texture_contents = Inventory.GetContents(texture_basefolder);
     foreach (InventoryBase c in texture_contents)
     {
         InventoryFolder subfolder = c as InventoryFolder;
         if (c is InventoryFolder)
        	{
             if (subfolder.Name == "ppt2os") {
             ppt2os_folder = subfolder.UUID;
             return ppt2os_folder;
             }
         }
     }
     //No folder yet
     if (ppt2os_folder == UUID.Zero) {
         client.Inventory.CreateFolder(texture_basefolder, "ppt2os");
         find_ppt2os_folder(client);
     }
     return ppt2os_folder;
 }
        public override bool Excecute(Automaton am, GridClient client, bool force)
        {
            if (!client.Network.Connected) { result.message = "Not Connected to grid"; return true; }
            if (string.IsNullOrEmpty(path)) path = "";

            string[] pth = path.Split('/');
            if (client.Inventory.Store == null)
            {
                result.message = "inventory not loaded";
                return true;
            }

            inv = client.Inventory.Store;

            InventoryFolder currentFolder = inv.RootFolder;
            if (currentFolder == null)
            {
                result.message = "inventory not loaded";
                return true;
            }
            for (int i = 0; i < pth.Length; ++i)
            {
                string nextName = pth[i];
                if (string.IsNullOrEmpty(nextName) || nextName == ".")
                    continue; // Ignore '.' and blanks, stay in the current directory.

                //List<InventoryBase> currentContents = Inventory.GetContents(currentFolder);
                List<InventoryBase> currentContents = inv.GetContents(currentFolder);
                // Try and find an InventoryBase with the corresponding name.
                bool found = false;
                foreach (InventoryBase item in currentContents)
                {
                    // Allow lookup by UUID as well as name:
                    if (item.Name == nextName || item.UUID.ToString() == nextName)
                    {
                        found = true;
                        if (item is InventoryFolder)
                        {
                            currentFolder = item as InventoryFolder;
                        }
                        else
                        {
                            result.message = "invalid path";
                            return true;
                        }
                    }
                }
                if (!found)
                {
                    result.message = "invalid path";
                    return true;
                }
            }

            List<InventoryBase> contents = inv.GetContents(currentFolder);

            client.Inventory.RequestFolderContents(currentFolder.UUID, client.Self.AgentID, true, true, InventorySortOrder.ByName);
            result.success = true;
            return true;
        }