File Module

This XQuery Module contains functions related to file system operations, such as listing, reading, or writing files.

This module is based on the EXPath File Module. The following enhancements have not been added to the specification yet:

=Conventions=

All functions and errors in this module are assigned to the  namespace, which is statically bound to the file prefix.

For serialization parameters, the  namespace is used, which is statically bound to the output prefix.

The error  is raised if a path is invalid.

File Paths

 * All file paths are resolved against the current working directory (the directory from which BaseX or, more generally, the Java Virtual Machine, was started). This directory can be retrieved via file:base-dir.


 * A path can be specified as local filesystem path or as file URI.


 * Returned strings that refer to existing directories are suffixed with a directory separator.

=Read Operations=

file:read-text-lines
=Write Operations=

file:move
=File Properties=

file:size
=Path Functions=

file:path-to-uri
=System Properties=

file:base-dir
=Errors=

=Changelog=


 * Version 9.0
 * Added: file:descendants
 * Updated: file:read-text-lines:  and   arguments added.


 * Version 8.5
 * Updated: file:read-text, file:read-text-lines:  argument added.


 * Version 8.2
 * Added: file:is-absolute
 * Updated: file:resolve-path: base argument added


 * Version 8.0
 * Added: file:current-dir, file:base-dir, file:children


 * Version 7.8
 * Added: file:parent, file:name
 * Updated: error codes; file:read-binary, file:write-binary: $offset and $length arguments added.
 * Deleted: file:base-name, file:dir-name


 * Version 7.7
 * Added: file:create-temp-dir, file:create-temp-file, file:temp-dir
 * Updated: all returned strings that refer to existing directories will be suffixed with a directory separator.


 * Version 7.3
 * Added: file:append-text, file:write-text, file:append-text-lines, file:write-text-lines, file:line-separator
 * Aligned with latest specification: $file:directory-separator → file:dir-separator, $file:path-separator → file:path-separator, file:is-directory → file:is-dir, file:create-directory → file:create-dir
 * Updated: file:write-binary, file:append-binary: output limited to a single value


 * Version 7.2.1
 * Updated: file:delete: $recursive parameter added to prevent sub-directories from being accidentally deleted.
 * Fixed: file:list now returns relative instead of absolute paths.