XQuery Function Documentation
http://exist-db.org/xquery/file
java:org.exist.xquery.modules.file.FileModule
A module for performing various operations on files and directories stored in the server file system.
file:delete #1
file:delete ($path as item()) as xs:boolean
Delete a file or directory. This method is only available to the DBA role.
- Parameters:
$path The full path or URI to the file - Returns:
- xs:boolean : true if successful, false otherwise
file:directory-list #2
file:directory-list ($path as item(), $pattern as xs:string*) as node()
List all files, including their file size and modification time, found in or below a directory, $directory. Files are located in the server's file system, using filename patterns, $pattern. File pattern matching is based on code from Apache's Ant, thus following the same conventions. For example:
'*.xml' matches any file ending with .xml in the current directory,
- '**/*.xml' matches files in any directory below the specified directory. This method is only available to the DBA role.
- Parameters:
$path The base directory path or URI in the file system where the files are located. $pattern The file name pattern - Returns:
- node()? : a node fragment that shows all matching filenames, including their file size and modification time, and the subdirectory they were found in
file:exists #1
file:exists ($path as item()) as xs:boolean
Tests if a file or directory exists. This method is only available to the DBA role.
- Parameters:
$path The full path or URI to the file in the file system - Returns:
- xs:boolean : the boolean value true if the file exists, false otherwise
file:is-directory #1
file:is-directory ($path as item()) as xs:boolean
Tests if a path is a directory. This method is only available to the DBA role.
- Parameters:
$path The full path or URI to the file or directory - Returns:
- xs:boolean : true if the path is a directory
file:is-readable #1
file:is-readable ($path as item()) as xs:boolean
Tests if a file is readable. This method is only available to the DBA role.
- Parameters:
$path The full path or URI to the file - Returns:
- xs:boolean : true if file can be read
file:is-writeable #1
file:is-writeable ($path as item()) as xs:boolean
Tests if a file is writeable. This method is only available to the DBA role.
- Parameters:
$path The full path or URI to the file - Returns:
- xs:boolean : true if the file has write permissions
file:list #1
file:list ($path as item()) as node()
List all files and directories under the specified directory. This method is only available to the DBA role.
- Parameters:
$path The directory path or URI in the file system. - Returns:
- node()* : a node describing file and directory names and meta data.
file:mkdir #1
file:mkdir ($path as item()) as xs:boolean
Create a directory. This method is only available to the DBA role.
- Parameters:
$path The full path or URI to the directory - Returns:
- xs:boolean : true if successful, false otherwise
file:mkdirs #1
file:mkdirs ($path as item()) as xs:boolean
Create a directory including any necessary but nonexistent parent directories. This method is only available to the DBA role.
- Parameters:
$path The full path or URI to the directory - Returns:
- xs:boolean : true if successful, false otherwise
file:move #2
file:move ($original as item(), $destination as item()) as xs:boolean
Move (rename) a file or directory. Exact operation is platform dependent. This method is only available to the DBA role.
- Parameters:
$original The full path or URI to the file $destination The full path or URI to the file - Returns:
- xs:boolean : true if successful, false otherwise
file:read #1
file:read ($path as item()) as xs:string
Reads the content of file. This method is only available to the DBA role.
- Parameters:
$path The directory path or URI in the file system. - Returns:
- xs:string? : the file contents
file:read #2
file:read ($path as item(), $encoding as xs:string) as xs:string
Reads the content of file. This method is only available to the DBA role.
- Parameters:
$path The directory path or URI in the file system. $encoding The encoding type for the file - Returns:
- xs:string? : the file contents
file:read-binary #1
file:read-binary ($path as item()) as xs:base64Binary
Reads the contents of a binary file. This method is only available to the DBA role.
- Parameters:
$path The directory path or URI in the file system. - Returns:
- xs:base64Binary? : the file contents
file:read-unicode #1
file:read-unicode ($path as item()) as xs:string
Reads the contents of a file. Unicode BOM (Byte Order Marker) will be stripped off if found. This method is only available to the DBA role.
- Parameters:
$path The directory path or URI in the file system. - Returns:
- xs:string? : the contents of the file
file:read-unicode #2
file:read-unicode ($path as item(), $encoding as xs:string) as xs:string
Reads the contents of a file. Unicode BOM (Byte Order Marker) will be stripped off if found. This method is only available to the DBA role.
- Parameters:
$path The directory path or URI in the file system. $encoding The file is read with the encoding specified. - Returns:
- xs:string? : the contents of the file
file:serialize #3
file:serialize ($node-set as node()*, $path as item(), $parameters as item()*) as xs:boolean
Writes the node set into a file on the file system. $parameters contains a sequence of zero or more serialization parameters specified as key=value pairs. The serialization options are the same as those recognized by "declare option exist:serialize". The function does NOT automatically inherit the serialization options of the XQuery it is called from. This method is only available to the DBA role.
- Parameters:
$node-set The contents to write to the file system. $path The full path or URI to the file $parameters The serialization parameters: either a sequence of key=value pairs or an output:serialization-parameters element as defined by the standard fn:serialize function. - Returns:
- xs:boolean? : true on success - false if the specified file can not be created or is not writable. The empty sequence is returned if the argument sequence is empty.
file:serialize #4
file:serialize ($node-set as node()*, $path as item(), $parameters as item()*, $append as xs:boolean) as xs:boolean
Writes the node set into a file on the file system, optionally appending to it. $parameters contains a sequence of zero or more serialization parameters specified as key=value pairs. The serialization options are the same as those recognized by "declare option exist:serialize". The function does NOT automatically inherit the serialization options of the XQuery it is called from. This method is only available to the DBA role.
- Parameters:
$node-set The contents to write to the file system. $path The full path or URI to the file $parameters The serialization parameters: either a sequence of key=value pairs or an output:serialization-parameters element as defined by the standard fn:serialize function. $append Should content be appended? - Returns:
- xs:boolean? : true on success - false if the specified file can not be created or is not writable. The empty sequence is returned if the argument sequence is empty.
file:serialize-binary #2
file:serialize-binary ($binarydata as xs:base64Binary, $path as item()) as xs:boolean
Writes binary data into a file on the file system. This method is only available to the DBA role.
- Parameters:
$binarydata The contents to write to the file system. $path The full path or URI to the file - Returns:
- xs:boolean : true on success - false if the specified file can not be created or is not writable
file:serialize-binary #3
file:serialize-binary ($binarydata as xs:base64Binary, $path as item(), $append as xs:boolean) as xs:boolean
Writes binary data into a file on the file system, optionally appending the content. This method is only available to the DBA role.
- Parameters:
$binarydata The contents to write to the file system. $path The full path or URI to the file $append Should content be appended? - Returns:
- xs:boolean : true on success - false if the specified file can not be created or is not writable
file:sync #3
file:sync ($collection as xs:string, $targetPath as item(), $dateTimeOrOptionsMap as item()?) as document-node()
Synchronize a collection with a directory hierarchy.This method is only available to the DBA role.
Read more- Parameters:
$collection Absolute path to the collection to synchronize to disk. $targetPath The path or URI to the target directory. Relative paths resolve against EXIST_HOME. $dateTimeOrOptionsMap Options as map(*). The available settings are:"prune": delete any file/dir that does not correspond to a doc/collection in the DB. "after": only resources modified after this date will be taken into account."excludes": files on the file system matching any of these patterns will be left untouched.(deprecated) If the third parameter is of type xs:dateTime, it is the same as setting the "after" option. - Returns:
- document-node() : A report (file:sync) which files and directories were updated (file:update) or deleted (file:delete).