Skip to content

File System Managers

Adrien Castex edited this page Jun 2, 2017 · 2 revisions

A file system manager (called FSManager because of its interface name) is an bundle of 3 methods and a property :

uid : string
newResource(fullPath : string, name : string, type : ResourceType, parent : IResource) : IResource;
serialize(resource : IResource, obj : SerializedObject) : object;
unserialize(data : any, obj : SerializedObject) : IResource;

The uid defines the unique name of the manager. When serialized, a resource description will have its file system manager referenced by its uid. This value allow to make the difference between two incompatible versions of a same file system manager. For instance, if an update of a file system manager class occurs and this change break the compatibility with the older version, then, the uid will be modified too.

The newResource method allow the server to create a new resource. This new resource will be created according to the name and type arguments. The fullpath and parent arguments are here to give more information about the context of the creation. This method MUST not call the create method of the resulting IResource instance, because the server will take care of this.

The serialize method is called when a resource must be serialized. This method returns an object containing only what the instance of the resource needs to be unserialized in the future, except for some data which are took care by the server itself. The SerializedObject instance argument is an object managed by the server. It contains some information : the manager's UID of the resource, its type and its children. The unserialize method is the other way around. For more information, look at the Persistence page.

class SerializedObject
{
    data : any // FSManager 'serialize(...)' result
    type : ResourceType // Type of the resource (provided by the 'type(...)' method of the resource)
    children : SerializedObject[] // List of serialized children (children resources to serialize are provided by the 'getChildren(...)' method of the resource if 'type.isDirectory === true')
    managerUID : string // The uid of the FSManager of the resource (provided by the 'fsmanager' property of the resource)
}
Clone this wiki locally