<?xml version="1.0" encoding="UTF-8"?><api:function-page xml:base="/apidoc/8.0/xdmp.directoryCreate.xml" generated="2015-10-07T16:36:00.016766-07:00" mode="javascript" xmlns:api="http://marklogic.com/rundmc/api"><api:function-name>xdmp.directoryCreate</api:function-name><api:suggest>xdmp.directorycreate</api:suggest><api:suggest>xdmp</api:suggest><api:suggest>directorycreate</api:suggest><api:function-link mode="xquery" fullname="xdmp:directory-create">/apidoc/8.0/xdmp:directory-create.xml</api:function-link><api:function mode="javascript" name="directoryCreate" type="builtin" lib="xdmp" category="UpdateBuiltins" hidden="false" bucket="MarkLogic Built-In Functions" prefix="xdmp" namespace="http://marklogic.com/xdmp" fullname="xdmp.directoryCreate"><api:summary>
  Creates a directory.  If security is enabled,
  the document permissions and collections are set to the given parameters,
  if supplied.  Otherwise, the current user's default permissions and/or
  collections are applied.  If the beginning of the document URI is
  protected, the user must have access to that URI privilege.  If the
  directory URI does not end with a '/' one is added.  If the directory already
  exists, then an XDMP-DIREXISTS exception is thrown.
</api:summary><api:params><api:param name="uri" type="xs:string"><api:param-description>
    The URI of the directory to be inserted.
  </api:param-description><api:param-name>uri</api:param-name><api:param-type>String</api:param-type></api:param><api:param class="javascript" name="permissions" type="Object[]" optional="true"><api:param-description>
    Security permission objects corresponding to the permissions
    for the document.
  </api:param-description><api:param-name>permissions</api:param-name><api:param-type>Object[]</api:param-type></api:param><api:param name="collections" type="xs:string*" optional="true"><api:param-description>
    The collections to which the new directory belongs.
  </api:param-description><api:param-name>collections</api:param-name><api:param-type>String[]</api:param-type></api:param><api:param name="quality" type="xs:int?" optional="true"><api:param-description>
    The quality of this document.  A positive value increases
    the relevance score of the document in text search functions.
    The converse is true for a negative value.  The default value is 0.
  </api:param-description><api:param-name>quality</api:param-name><api:param-type>xs.int?</api:param-type></api:param><api:param name="forest-ids" type="xs:unsignedLong*" optional="true"><api:param-description>
    Specifies the ID of the forest in which this directory is created.
    If the directory already exists in the database and if $forest-ids is
    not specified, it will remain in its existing forest.  If no such
    forest exists or if no such forest is attached to the context database,
    an error is raised.  If multiple forests are specified, the directory
    is created in one of the specifed forests.
    <p xmlns="http://www.w3.org/1999/xhtml">
    If you have local disk failover enabled, specify the ID of the master 
    forest.  In the event of a failover, MarkLogic server will automatically 
    redirect documents to the replica forest.  Specify the ID of the replica 
    forest will result in a "forest not in database" error.
    </p>
  </api:param-description><api:param-name>forest-ids</api:param-name><api:param-type>String[]</api:param-type></api:param></api:params><api:return>null</api:return><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
declareUpdate();
xdmp.directoryCreate("http://marklogic.com/a/",
            [xdmp.permission("development", "update"),
             xdmp.permission("qa", "read")],
             "http://marklogic.com/directories");

=&gt; Creates a directory named "http://marklogic.com/a/",
   which has the parent directory "http://marklogic.com/".
   The directory is created with the specified permissions,
   and is added to the "http://marklogic.com/directories"
   collection.  

</pre></api:example><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
declareUpdate();
xdmp.directoryCreate("/dir/myDirectory/");

=&gt; Creates a directory named "/dir/myDirectory/",
   which has the parent directory "/dir/", which
   in turn has parent directory "/". If
   directory creation is set to automatic in
   the database configuration, this example creates
   all three directories ("/", "/dir/", and
    "/dir/myDirectory/").  

</pre></api:example></api:function></api:function-page>