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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Synchronize a collection with a directory hierarchy. Compares last modified time stamps. If $dateTime is given, only resources modified after this time stamp are taken into account. This method is only available to the DBA role.
- Parameters:
-
$collection The collection to sync. $targetPath The full path or URI to the directory $dateTime? Optional: only resources modified after the given date/time will be synchronized. - Returns:
- xs:boolean : true if successful, false otherwise