Inventory Manipulation using Path-Based Commands

6 October 2016

  • Release 9.133 - The command now can take a path instead of a name.

11 September 2016

  • Release 9.122 - added the ability to rename and name items using the mv action.

28 March 2015

  • Release 7.86 - added the actions cp (copy an item), mv (move an item), ln (create an item link).

25 March 2015

  • Release 7.83 - added.
inventory (Commands)
TypeCorrade progressive command
Commandinventory
DescriptionThe inventory commands allows an user to manipulate Corrade's inventory by using a set of commands comparable to UNIX commands for manipulating directory paths.
Permissionsinventory
Parametersgroup, password, action
Last ChangesRelease 9.133 - The command now can take a path instead of a name.

The inventory commands allows an user to manipulate Corrade's inventory by using a set of commands comparable to UNIX commands for manipulating directory paths. When Corrade is started, each group has its own unique current directory set to My Inventory, which can then be manipulated and altered separately by each group in part.

Command Required Parameters Required Corrade Permissions Example
inventory group, password, action inventory
llInstantMessage(CORRADE,
    wasKeyValueEncode(
        [
            // show current directory.
            "command", "inventory",
            "group", wasURLEscape(GROUP),
            "password", wasURLEscape(PASSWORD),
            "action", "cwd"
        ]
    )
);
Action Required Parameter Optional Parameter Description
ls path Lists the contents of the current folder with an optional path.
cwd List the current directory.
cd path Changes directory to the folder specified by the path.
mkdir name path Creates a directory specified by name at a given optional path - or, inside the current directory, if the path is not specified.
chmod permissions path Sets the permissions on the items in the current directory, or in a directory specified by path or an item in the path.
rm path Moves everything in the current directory or the item specified by path to the Trash folder.
cp source Copies an item specified by the source path to the target. The target can be either a folder or a path ending in a name.
target
mv source Moves an item specified by the source path to the target. The target can be either a folder or a path ending in a name. When the target ends in a name, the mv action functions as a rename.
target
ln source Creates a link from the source path to the target folder. Note that the source must be the path to an item and that folders are not supported. The target can be either a folder or a path ending in a name.
target

Specifying Paths

One of the problems with Linden protocols is that inventory items may carry the same name, which is something that filesystems usually do not support, which makes referring to an item by name ambiguous. To overcome this problem, Corrade allows the path parameter to be built by name or by UUID or a combination thereof.

As an example, consider the following tree:

   + My Inventory (UUID: 7c38c488-5440-46c2-9f14-d5e3fcd0cc16)
   |
   +- Textures (UUID: 56a54ebe-7d4d-4839-a618-42ee3b307717)
         +
         |
         +- Floors (UUID: b13b0890-fac6-4085-975c-c2f760b185e4)
         |    +
         |    |
         |    +- Deck (UUID: 3e51dd70-9cd8-4dcf-9465-58c7036e673d)
         |
         +- Floors (UUID: c590792b-a724-4bb6-9f0c-81b6e733fad5)
              +
              |
              +- Table (UUID: 6eaffc93-df2a-479b-836b-4778bb917619)

If we wanted to list Deck and supposing that we are currently in My Inventory which is the root, then supplying /My Inventory/Textures/Floors/Deck to the path parameter would be ambiguous since it is uncertain which Floors folder should be browsed. To get rid of the Linden ambiguity, Corrade allows specifying UUIDs in the paths such that we are able to correctly reference Deck by supplying: /My Inventory/Textures/b13b0890-fac6-4085-975c-c2f760b185e4/Deck to the path parameter. Note that it is also possible to specify any of the other path components as UUIDs rather than by names - yet, in this case, that is not necessary: when you supply a name in the path, you are making a weak reference, when you are supplying an UUID you are making a strong reference.

Escaping Path Components Containing Forward-Slash Characters

Items that contain a forward-slash that would clash with the forward-slash (/) representing a path component can be escaped using a backslash (\). For instance, suppose that you have a texture named:

// Awesome Texture //

and that you want to reference it - you would then write:

"path" , wasURLEscape("/My Inventory/Textures/\/\/ Awesome Texture \/\/");

Alternatively, you can just use the UUID instead of the name.

Permissions

This command uses the Corrade permissions notation. As an example, let us enumerate a notecard called test and placed in the Notecards sub-folder of My Inventory:

llInstantMessage(CORRADE, 
    wasKeyValueEncode(
        [
            // show current directory.
            "command", "inventory",
            "group", wasURLEscape(GROUP),
            "password", wasURLEscape(PASSWORD),
            "action", "ls",
            "path", wasURLEscape("/My Inventory/Notecards/test"),
            "callback", wasURLEscape(URL)
        ]
    )
);

the callback will receive a data key with the following CSV:

name, test, item, b815f8e4-0367-b361-9227-f1ab7e036eef, type, notecard, permissions, c--mvt------------c--mvtc--mvt

we can thus observe that the permissions for the test notecard are:

c--mvt------------c--mvtc--mvt

these permissions are similar to UNIX commands and are compatible with Corrade's chmod action of the inventory command. They describe all the permissions governing our test notecard.

To dissect these permissions, you can use the following guide:

  • split that string in segments of 6 characters: cdemvt, ------, ------, cdemvt, cdemvt.
  • each segment means, in order: base permissions, everyone permissions, group permissions, next owner permissions, owner permissions.
  • each character means, in order: c (copy), d (damage), e (export), m (modify), v (move), t (transfer).
    • if any of the previously mentioned characters are missing and have a dash (-) instead, that means that the permissions is missing.

Suppose that we wanted to change the permissions for the next owner and remove the modify permissions. We would then issue the following command:

llInstantMessage(CORRADE, 
    wasKeyValueEncode(
        [
            // show current directory.
            "command", "inventory",
            "group", wasURLEscape(GROUP),
            "password", wasURLEscape(PASSWORD),
            "action", "chmod",
            "path", wasURLEscape("/My Inventory/Notecards/test"),
            "permissions", wasURLEscape("c--mvt------------c---vtc--mvt"),
            "callback", wasURLEscape(URL)
        ]
    )
);

The original permissions for the test notecard were:

c--mvt------------c--mvtc--mvt

and the new permissions are now:

c--mvt------------c---vtc--mvt

As you can see, the 4th segment which refers to the next owner permissions is missing the m component, meaning that it cannot be modified.


secondlife/scripted_agents/corrade/api/progressive/commands/inventory.txt ยท Last modified: 2017/04/13 16:11 by Wizardry and Steamworks

Access website using Tor


For the copyright, license, warranty and privacy terms for the usage of this website please see the license and privacy pages.