A RESTful browser for eXist Function Modules


http://exist-db.org/xquery/file
A module for performing various operations on files and directories stored in the server file system.

file:delete($filepath as item()) xs:boolean
Delete a file or directory. This method is only available to the DBA role.
$filepathThe full path to the file

Returns true if successful, false otherwise

file:directory-list($directory as xs:string, $pattern as xs:string) 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.
$directoryThe base directory path in the file system where the files are located.
$patternThe file name pattern

Returns a node fragment that shows all matching filenames, including their file size and modification time, and the subdirectory they were found in

file:exists($filepath as item()) xs:boolean
Tests if a file or directory exists. This method is only available to the DBA role.
$filepathThe full path to the file in the file system

Returns the boolean value true if the file exists, false otherwise

file:is-directory($path as item()) xs:boolean
Tests if a path is a directory. This method is only available to the DBA role.
$pathThe full path to the file or directory

Returns true if the path is a directory

file:is-readable($filepath as item()) xs:boolean
Tests if a file is readable. This method is only available to the DBA role.
$filepathThe full path to the file

Returns true if file can be read

file:is-writeable($filepath as item()) xs:boolean
Tests if a file is writeable. This method is only available to the DBA role.
$filepathThe full path to the file

Returns true if the file has write permissions

file:list($directory as xs:string) node()*
List all files and directories under the specified directory. This method is only available to the DBA role.
$directoryThe directory path in the file system.

Returns a node describing file and directory names and meta data.

file:mkdir($filepath as item()) xs:boolean
Create a directory. This method is only available to the DBA role.
$filepathThe full path to the directory

Returns true if successful, false otherwise

file:mkdirs($filepath as item()) xs:boolean
Create a directory including any necessary but nonexistent parent directories. This method is only available to the DBA role.
$filepathThe full path to the directory

Returns true if successful, false otherwise

file:move($original as item(), $destination as item()) xs:boolean
Move (rename) a file or directory. Exact operation is platform dependent. This method is only available to the DBA role.
$originalThe full path to the file
$destinationThe full path to the file

Returns true if successful, false otherwise

file:read($url as item()) xs:string?
Reads the content of file. This method is only available to the DBA role.
$urlA string representing a URL, eg file://etc.

Returns the file contents

file:read($url as item(), $encoding as xs:string) xs:string?
Reads the content of file. This method is only available to the DBA role.
$urlA string representing a URL, eg file://etc.
$encodingThe encoding type for the file

Returns the file contents

file:read-binary($url as item()) xs:base64Binary?
Reads the contents of a binary file. This method is only available to the DBA role.
$urlA string representing a URL, eg file://etc.

Returns the file contents

file:read-unicode($url as item()) 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.
$urlThe URL to the file, e.g. file://etc.

Returns the contents of the file

file:read-unicode($url as item(), $encoding as xs:string) 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.
$urlThe URL to the file, e.g. file://etc.
$encodingThe file is read with the encoding specified.

Returns the contents of the file

file:serialize($node-set as node()*, $filepath as xs:string, $parameters as xs:string*) 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.
$node-setThe contents to write to the file system.
$filepathThe full path to the file
$parametersThe serialization parameters specified as key-value pairs

Returns 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($node-set as node()*, $filepath as xs:string, $parameters as xs:string*, $append as xs:boolean) 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.
$node-setThe contents to write to the file system.
$filepathThe full path to the file
$parametersThe serialization parameters specified as key-value pairs
$appendShould content be appended?

Returns 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($binarydata as xs:base64Binary, $filepath as xs:string) xs:boolean
Writes binary data into a file on the file system. This method is only available to the DBA role.
$binarydataThe contents to write to the file system.
$filepathThe full path to the file

Returns true on success - false if the specified file can not be created or is not writable

file:serialize-binary($binarydata as xs:base64Binary, $filepath as xs:string, $append as xs:boolean) 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.
$binarydataThe contents to write to the file system.
$filepathThe full path to the file
$appendShould content be appended?

Returns true on success - false if the specified file can not be created or is not writable

file:sync($collection as xs:string, $targetPath as xs:string, $dateTime as xs:dateTime?) xs:boolean
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.
$collectionThe collection to sync.
$targetPathThe full path to the directory
$dateTimeOptional: only resources modified after the given date/time will be synchronized.

Returns true if successful, false otherwise
Return to list of all modules