http://expath.org/ns/file

Description

Before using any of the functions below please remember to import the module namespace:

import module namespace file = "http://expath.org/ns/file";

This module implements the file API EXPath specification available at http://expath.org/spec/file

Module code

Here is the actual XQuery module code.

See also

Authors

Gabriel Petrovay, Matthias Brantner, Markus Pilman

Version Declaration

xquery version "3.0" encoding "utf-8";

Namespaces

anhttp://zorba.io/annotations
filehttp://expath.org/ns/file
verhttp://zorba.io/options/versioning

Function Summary

append-binary($file as xs:string, $content as xs:base64Binary) as empty-sequence() external

Appends a sequence of Base64 items as binary to a file.

append-text($file as xs:string, $content as xs:string, $encoding as xs:string) as empty-sequence() external

Appends a sequence of string items to a file.

append-text($file as xs:string, $content as xs:string) as empty-sequence()

Appends a sequence of string items to a file.

append-text-lines($file as xs:string, $content as xs:string*, $encoding as xs:string) as empty-sequence() external

Appends a sequence of string items to a file, each followed by a platform-dependent newline character(s).

append-text-lines($file as xs:string, $content as xs:string*) as empty-sequence()

Appends a sequence of string to a file, each followed by a platform-dependent newline character(s), using the UTF-8 character encoding.

base-name($path as xs:string) as xs:string external

Returns the last component from the $path , deleting any trailing directory-separator characters.

base-name($path as xs:string, $suffix as xs:string) as xs:string

Returns the last component from the $path , deleting any trailing directory-separator characters and the $suffix .

copy($source as xs:string, $destination as xs:string) as empty-sequence()

Copies a file or a directory given a source and a destination path/URI.

create-directory($dir as xs:string) as empty-sequence() external

Creates a directory.

delete($path as xs:string) as empty-sequence()

Deletes a file or a directory from the file system.

directory-separator() as xs:string external

This function returns the value of the operating system specific directory separator.

dir-name($path as xs:string) as xs:string external

This function is the converse of file:base-name .

exists($path as xs:string, $follow-symlinks as xs:boolean) as xs:boolean external

Tests if a path/URI is already used in the file system.

exists($path as xs:string) as xs:boolean

Tests if a path/URI is already used in the file system.

glob-to-regex($pattern as xs:string) as xs:string

A helper function that performs a trivial (not complete) glob to regex pattern translation.

is-directory($path as xs:string) as xs:boolean external

Tests if a path/URI points to a directory.

is-file($path as xs:string) as xs:boolean external

Tests if a path/URI points to a file.

is-symlink($path as xs:string) as xs:boolean external

Tests if a path/URI points to symbolic link.

last-modified($path as xs:string) as xs:dateTime external

Retrieves the timestamp of the last modification of the file system item pointed by the path/URI.

list($dir as xs:string) as xs:string* external

Lists the file system items in a certain directory.

list($path as xs:string, $recursive as xs:boolean) as xs:string*

Lists the file system items in a certain directory.

list($path as xs:string, $recursive as xs:boolean, $pattern as xs:string) as xs:string*

Lists all files matching the given pattern in a given directory.

move($source as xs:string, $destination as xs:string) as empty-sequence()

Moves a file or directory given a source and a destination paths/URIs.

path-separator() as xs:string external

This function returns the value of the operating system specific path separator.

path-to-native($path as xs:string) as xs:string external

Transforms a URI, an absolute path, or relative path to a native path on the running platform.

path-to-uri($path as xs:string) as xs:anyURI external

Transforms a file system path into a URI with the file:// scheme.

read-binary($file as xs:string) as xs:base64Binary external

Reads the content of a file and returns a Base64 representation of the content.

read-text($file as xs:string, $encoding as xs:string) as xs:string external

Reads the content of a file using the specified encoding and returns a string representation of the content.

read-text($file as xs:string) as xs:string

Reads the content of a file and returns a string representation of the content.

read-text-lines($file as xs:string) as xs:string*

Reads the content of a file and returns a sequence of strings representing the lines in the content of the file.

read-text-lines($file as xs:string, $encoding as xs:string) as xs:string* external

Reads the content of a file using the specified encoding and returns a sequence of strings representing the lines in the content of the file.

resolve-path($path as xs:string) as xs:string external

Transforms a relative path/URI into an absolute operating system path by resolving it against the current working directory.

size($file as xs:string) as xs:integer external

Retrieves the size of a file.

write-binary($file as xs:string, $content as xs:base64Binary) as empty-sequence() external

Writes a sequence of Base64 items as binary to a file.

write-text($file as xs:string, $content as xs:string, $encoding as xs:string) as empty-sequence() external

Writes a sequence of strings to a file.

write-text($file as xs:string, $content as xs:string) as empty-sequence()

Writes a sequence of strings to a file using the UTF-8 character encoding.

write-text-lines($file as xs:string, $content as xs:string*, $encoding as xs:string) as empty-sequence() external

Writes a sequence of strings to a file, each followed by a platform-dependent newline character(s).

write-text-lines($file as xs:string, $content as xs:string*) as empty-sequence()

Writes a sequence of strings to a file, each followed by a platform-dependent newline character(s), using the UTF-8 character encoding.

copy-file-impl($sourceFile as xs:string, $destination as xs:string) as empty-sequence() external

Copies a file given a source and a destination path/URI.

copy-directory-impl($sourceDir as xs:string, $destination as xs:string) as empty-sequence()

Copies a source directory recursively to a destination path/URI.

copy-directory($sourceDir as xs:string, $destinationDir as xs:string) as empty-sequence()

This is an internal function that copies an entire source directory to an destination directory.

copy-directory-content($sourceDir as xs:string, $destination as xs:string) as empty-sequence()

Copies the content of a given directory to an existing destination directory.

delete-file-impl($file as xs:string) as empty-sequence() external

Deletes a file from the file system.

delete-directory-impl($dir as xs:string) as empty-sequence()

Deletes a directory from the file system.

Functions

append-binary#2

declare %an:sequential function file:append-binary(
    $file as xs:string,
    $content as xs:base64Binary
) as empty-sequence() external
Appends a sequence of Base64 items as binary to a file. If the file pointed by
$file
does not exist, a new file will be created.

Parameters

  • $file

    The path/URI of the file to write the content to.

  • $content

    The content to be written to the file.

Returns

  • empty-sequence()

    The empty sequence.

Errors

  • file:FOFL0004

    If $file points to a directory.

  • file:FOFL9999

    If any other error occurs.

append-text#3

declare %an:sequential function file:append-text(
    $file as xs:string,
    $content as xs:string,
    $encoding as xs:string
) as empty-sequence() external

Appends a sequence of string items to a file.

Parameters

  • $file

    The path/URI of the file to write the content to.

  • $content

    The content to be written to the file.

  • $encoding

    The character encoding to append $content as.

Returns

  • empty-sequence()

    The empty sequence.

Errors

  • file:FOFL0004

    If $file points to a directory.

  • file:FOFL9999

    If any other error occurs.

append-text#2

declare %an:sequential function file:append-text(
    $file as xs:string,
    $content as xs:string
) as empty-sequence()

Appends a sequence of string items to a file.

Parameters

  • $file

    The path/URI of the file to write the content to.

  • $content

    The content to be written to the file.

Returns

  • empty-sequence()

    The empty sequence.

Errors

  • file:FOFL0004

    If $file points to a directory.

  • file:FOFL9999

    If any other error occurs.

append-text-lines#3

declare %an:sequential function file:append-text-lines(
    $file as xs:string,
    $content as xs:string*,
    $encoding as xs:string
) as empty-sequence() external

Appends a sequence of string items to a file, each followed by a platform-dependent newline character(s).

Parameters

  • $file

    The path/URI of the file to write the content to.

  • $content

    The content to be written to the file.

  • $encoding

    The character encoding to append $content as.

Returns

  • empty-sequence()

    The empty sequence.

Errors

  • file:FOFL0004

    If $file points to a directory.

  • file:FOFL9999

    If any other error occurs.

append-text-lines#2

declare %an:sequential function file:append-text-lines(
    $file as xs:string,
    $content as xs:string*
) as empty-sequence()

Appends a sequence of string to a file, each followed by a platform-dependent newline character(s), using the UTF-8 character encoding.

Parameters

  • $file

    The path/URI of the file to write the content to.

  • $content

    The content to be written to the file.

Returns

  • empty-sequence()

    The empty sequence.

Errors

  • file:FOFL0004

    If $file points to a directory.

  • file:FOFL9999

    If any other error occurs.

base-name#1

declare function file:base-name(
    $path as xs:string
) as xs:string external
Returns the last component from the
$path
, deleting any trailing directory-separator characters. If
$path
consists entirely directory-separator characters, the empty string is returned. If
$path
is the empty string, the string
"."
is returned, signifying the current directory. No path existence check is made.

Parameters

  • $path

    A file path/URI.

Returns

  • xs:string

    The base name of this file.

base-name#2

declare function file:base-name(
    $path as xs:string,
    $suffix as xs:string
) as xs:string
Returns the last component from the
$path
, deleting any trailing directory-separator characters and the
$suffix
. If path consists entirely directory-separator characters, the empty string is returned. If path is the empty string, the string
"."
is returned, signifying the current directory. No path existence check is made. The
$suffix
can be used for example to eliminate file extensions.

Parameters

  • $path

    A file path/URI.

  • $suffix

    A suffix which should get deleted from the result.

Returns

  • xs:string

    The base-name of $path with a deleted $suffix.

copy#2

declare %an:nondeterministic %an:sequential function file:copy(
    $source as xs:string,
    $destination as xs:string
) as empty-sequence()

Copies a file or a directory given a source and a destination path/URI.

Parameters

  • $source

    The path/URI of the file or directory to copy.

  • $destination

    The destination path/URI.

Returns

  • empty-sequence()

    The empty sequence.

Errors

  • file:FOFL0001

    If the $source path does not exist.

  • file:FOFL0002

    If the computed destination points to a file system item with a different type than the $source.

  • file:FOFL0003

    If $destination does not exist and it's parent directory does not exist either.

  • file:FOFL9999

    If any other error occurs.

create-directory#1

declare %an:sequential function file:create-directory(
    $dir as xs:string
) as empty-sequence() external

Creates a directory. The operation is will create all the missing parent directories from the given path.

Parameters

  • $dir

    The path/URI denoting the directory to be created.

Returns

  • empty-sequence()

    The empty sequence.

Errors

  • file:FOFL0002

    If the directory cannot be created because of an already existing file.

  • file:FOFL9999

    If any other error occurs.

delete#1

declare %an:nondeterministic %an:sequential function file:delete(
    $path as xs:string
) as empty-sequence()
Deletes a file or a directory from the file system. If
$path
points to a directory the directory will be deleted recursively.

Parameters

  • $path

    The path/URI of the file or directory to delete.

Returns

  • empty-sequence()

    The empty sequence.

Errors

  • file:FOFL0001

    If the $path path does not exist.

  • file:FOFL9999

    If any other error occurs.

directory-separator#0

declare function file:directory-separator() as xs:string external
This function returns the value of the operating system specific directory separator. For example,
/
on Unix-based systems and
\
on Windows systems.

Returns

  • xs:string

    The operating system specific directory separator.

dir-name#1

declare function file:dir-name(
    $path as xs:string
) as xs:string external
This function is the converse of
file:base-name
. It returns a string denoting the parent directory of the
$path
. Any trailing directory-separator characters are not counted as part of the directory name. If path is the empty string or contains no directory-separator string,
"."
is returned, signifying the current directory. No path existence check is made.

Parameters

  • $path

    The filename, of which the dirname should be get.

Returns

  • xs:string

    The name of the directory the file is in.

exists#2

declare %an:nondeterministic function file:exists(
    $path as xs:string,
    $follow-symlinks as xs:boolean
) as xs:boolean external

Tests if a path/URI is already used in the file system.

Parameters

  • $path

    The path/URI to test.

  • $follow-symlinks

    if true, follows symbolic links.

Returns

  • xs:boolean

    true if $path points to an existing file system item.

exists#1

declare %an:nondeterministic function file:exists(
    $path as xs:string
) as xs:boolean

Tests if a path/URI is already used in the file system.

Parameters

  • $path

    The path/URI to test.

Returns

  • xs:boolean

    true if $path points to an existing file system item; for symbolic links, retuns true if the linked-to item exists.

glob-to-regex#1

declare function file:glob-to-regex(
    $pattern as xs:string
) as xs:string

A helper function that performs a trivial (not complete) glob to regex pattern translation.

Parameters

  • $pattern

    The glob pattern.

Returns

  • xs:string

    A regex pattern corresponding to the glob pattern provided.

is-directory#1

declare %an:nondeterministic function file:is-directory(
    $path as xs:string
) as xs:boolean external

Tests if a path/URI points to a directory. On Unix-based systems, the root and the volume roots are considered directories.

Parameters

  • $path

    The path/URI to test.

Returns

  • xs:boolean

    true if $path points to a directory; for symbolic links, returns true if the linked-to item is a directory.

is-file#1

declare %an:nondeterministic function file:is-file(
    $path as xs:string
) as xs:boolean external

Tests if a path/URI points to a file.

Parameters

  • $path

    The path/URI to test.

Returns

  • xs:boolean

    true if $path points to a file; for symbolic links, returns true if the linked-to item is a file.

declare %an:nondeterministic function file:is-symlink(
    $path as xs:string
) as xs:boolean external

Tests if a path/URI points to symbolic link. This works on all Unix-based systems as well as Windows Vista or later.

Parameters

  • $path

    The path/URI to test.

Returns

  • xs:boolean

    true if $path points to a symbolic link.

last-modified#1

declare %an:nondeterministic function file:last-modified(
    $path as xs:string
) as xs:dateTime external

Retrieves the timestamp of the last modification of the file system item pointed by the path/URI.

Parameters

  • $path

    The file system item to read the last modification timestamp from.

Returns

  • xs:dateTime

    The date and time of the last modification of the item.

Errors

  • file:FOFL0001

    If the $path does not exist.

  • file:FOFL9999

    If any other error occurs.

list#1

declare %an:nondeterministic function file:list(
    $dir as xs:string
) as xs:string* external
Lists the file system items in a certain directory. The operation is equivalent to calling:
file:list($dir, fn:false())
.

Parameters

  • $dir

    The path/URI of the directory to retrieve the children from.

Returns

  • xs:string*

    The sequence of names of the direct children.

Errors

  • file:FOFL0003

    If $dir does not point to an existing directory.

  • file:FOFL9999

    If any other error occurs.

list#2

declare %an:nondeterministic function file:list(
    $path as xs:string,
    $recursive as xs:boolean
) as xs:string*
Lists the file system items in a certain directory. The order of the items in the resulting sequence is not defined. The "." and ".." items are not returned. The returned paths are relative to the provided
$path
. If
$recursive
evaluates to
fn:true()
, the operation will recurse in the subdirectories.

Parameters

  • $dir

    The path/URI to retrieve the children from.

  • $recursive

    A boolean flag indicating whether the operation should be performed recursively.

Returns

  • xs:string*

    A sequence of relative paths.

Errors

  • file:FOFL0003

    If $dir does not point to an existing directory.

  • file:FOFL9999

    If any other error occurs.

list#3

declare %an:nondeterministic function file:list(
    $path as xs:string,
    $recursive as xs:boolean,
    $pattern as xs:string
) as xs:string*
Lists all files matching the given pattern in a given directory. The order of the items in the result is not defined. The "." and ".." items are not considered for the match. The file paths are relative to the provided $path. The pattern is a glob expression supporting:
  • *
    for matching any number of unknown characters
  • ?
    for matching one unknown character

Parameters

  • $path

    The path/URI to retrieve the children from.

  • $recursive

    A boolean flag indicating whether the operation should be performed recursively.

  • $pattern

    The file name pattern.

Returns

  • xs:string*

    A sequence of file names matching the pattern.

Errors

  • file:FOFL0003

    If $dir does not point to an existing directory.

  • file:FOFL9999

    If any other error occurs.

move#2

declare %an:sequential function file:move(
    $source as xs:string,
    $destination as xs:string
) as empty-sequence()

Moves a file or directory given a source and a destination paths/URIs.

Parameters

  • $source

    The path/URI of the file to move.

  • $destination

    The destination path/URI.

Returns

  • empty-sequence()

    The empty sequence.

Errors

  • file:FOFL0001

    If the $source path does not exist.

  • file:FOFL0002

    If $source points to a directory and $destination points to an existing file.

  • file:FOFL0003

    If $destination does not exist and its parent directory does not exist either.

  • file:FOFL9999

    If any other error occurs.

path-separator#0

declare function file:path-separator() as xs:string external
This function returns the value of the operating system specific path separator. For example,
:
on Unix-based systems and
;
on Windows systems.

Returns

  • xs:string

    The operating system specific path separator.

path-to-native#1

declare function file:path-to-native(
    $path as xs:string
) as xs:string external

Transforms a URI, an absolute path, or relative path to a native path on the running platform. No path existence check is made.

Parameters

  • $path

    The uri or path to normalize.

Returns

  • xs:string

    The native path corresponding to $path.

Errors

  • file:FOFL9999

    If an error occurs while trying to obtain the native path.

path-to-uri#1

declare function file:path-to-uri(
    $path as xs:string
) as xs:anyURI external

Transforms a file system path into a URI with the file:// scheme. If the path is relative, it is first resolved against the current working directory. No path existence check is made.

Parameters

  • $path

    The path to transform.

Returns

  • xs:anyURI

    The file URI corresponding to path.

read-binary#1

declare %an:nondeterministic function file:read-binary(
    $file as xs:string
) as xs:base64Binary external

Reads the content of a file and returns a Base64 representation of the content.

Parameters

  • $file

    The file to read.

Returns

  • xs:base64Binary

    The content of the file as Base64.

Errors

  • file:FOFL0001

    If the $source path does not exist.

  • file:FOFL0004

    If $source points to a directory.

  • file:FOFL9999

    If any other error occurs.

read-text#2

declare %an:nondeterministic function file:read-text(
    $file as xs:string,
    $encoding as xs:string
) as xs:string external

Reads the content of a file using the specified encoding and returns a string representation of the content.

Parameters

  • $file

    The file to read.

  • $encoding

    The encoding used when reading the file. If compiled with ICU, then Zorba supports any encoding that ICU supports; otherwise Zorba only supports ASCII and UTF-8. The encoding parameter is case insensitive.

Returns

  • xs:string

    The content of the file as string.

Errors

  • file:FOFL0001

    If the $source path does not exist.

  • file:FOFL0004

    If $source points to a directory.

  • file:FOFL0006

    If $encoding is not supported.

  • file:FOFL9999

    If any other error occurs.

read-text#1

declare %an:nondeterministic function file:read-text(
    $file as xs:string
) as xs:string
Reads the content of a file and returns a string representation of the content. The operation is equivalent to calling:
file:read-text($file, "UTF-8")
.

Parameters

  • $file

    The file to read.

Returns

  • xs:string

    The content of the file as string.

Errors

  • file:FOFL0001

    If the $source path does not exist.

  • file:FOFL0004

    If $source points to a directory.

  • file:FOFL9999

    If any other error occurs.

read-text-lines#1

declare %an:nondeterministic function file:read-text-lines(
    $file as xs:string
) as xs:string*
Reads the content of a file and returns a sequence of strings representing the lines in the content of the file. The operation is equivalent to calling:
file:read-text-lines($file, "UTF-8")
.

Parameters

  • $file

    The file to read.

Returns

  • xs:string*

    The content of the file as a sequence of strings.

Errors

  • file:FOFL0001

    If the $source path does not exist.

  • file:FOFL0004

    If $source points to a directory.

  • file:FOFL9999

    If any other error occurs.

read-text-lines#2

declare %an:nondeterministic function file:read-text-lines(
    $file as xs:string,
    $encoding as xs:string
) as xs:string* external

Reads the content of a file using the specified encoding and returns a sequence of strings representing the lines in the content of the file. This implementation considers the LF ( ) character as the line separator. If a resulting line ends with the CR ( ) character, this is trimmed as well. This implementation will uniformly treat LF and CRLF as line separators.

Parameters

  • $file

    The file to read.

  • $encoding

    The encoding used when reading the file. If compiled with ICU, then Zorba supports any encoding that ICU supports; otherwise Zorba only supports ASCII and UTF-8. The encoding parameter is case insensitive.

Returns

  • xs:string*

    The content of the file as a sequence of strings.

Errors

  • file:FOFL0001

    If the $source path does not exist.

  • file:FOFL0004

    If $source points to a directory.

  • file:FOFL0006

    If $encoding is not supported.

  • file:FOFL9999

    If any other error occurs.

resolve-path#1

declare function file:resolve-path(
    $path as xs:string
) as xs:string external

Transforms a relative path/URI into an absolute operating system path by resolving it against the current working directory. No path existence check is made.

Parameters

  • $path

    The path/URI to transform.

Returns

  • xs:string

    The operating system file path.

size#1

declare %an:nondeterministic function file:size(
    $file as xs:string
) as xs:integer external

Retrieves the size of a file.

Parameters

  • $file

    The file get the size.

Returns

  • xs:integer

    An integer representing the size in bytes of the file.

Errors

  • file:FOFL0001

    If the $file does not exist.

  • file:FOFL0004

    If the $file points to a directory.

  • file:FOFL9999

    If any other error occurs.

write-binary#2

declare %an:sequential function file:write-binary(
    $file as xs:string,
    $content as xs:base64Binary
) as empty-sequence() external

Writes a sequence of Base64 items as binary to a file.

Parameters

  • $file

    The path/URI of the file to write the content to.

  • $content

    The content to be written to the file.

Returns

  • empty-sequence()

    The empty sequence.

Errors

  • file:FOFL0004

    If $file points to a directory.

  • file:FOFL9999

    If any other error occurs.

write-text#3

declare %an:sequential function file:write-text(
    $file as xs:string,
    $content as xs:string,
    $encoding as xs:string
) as empty-sequence() external

Writes a sequence of strings to a file.

Parameters

  • $file

    The path/URI of the file to write the content to.

  • $content

    The content to be written to the file.

  • $encoding

    The character encoding to write $content as.

Returns

  • empty-sequence()

    The empty sequence.

Errors

  • file:FOFL0004

    If $file points to a directory.

  • file:FOFL9999

    If any other error occurs.

write-text#2

declare %an:sequential function file:write-text(
    $file as xs:string,
    $content as xs:string
) as empty-sequence()

Writes a sequence of strings to a file using the UTF-8 character encoding.

Parameters

  • $file

    The path/URI of the file to write the content to.

  • $content

    The content to be written to the file.

Returns

  • empty-sequence()

    The empty sequence.

Errors

  • file:FOFL0004

    If $file points to a directory.

  • file:FOFL9999

    If any other error occurs.

write-text-lines#3

declare %an:sequential function file:write-text-lines(
    $file as xs:string,
    $content as xs:string*,
    $encoding as xs:string
) as empty-sequence() external

Writes a sequence of strings to a file, each followed by a platform-dependent newline character(s).

Parameters

  • $file

    The path/URI of the file to write the content to.

  • $content

    The content to be written to the file.

  • $encoding

    The character encoding to write $content as.

Returns

  • empty-sequence()

    The empty sequence.

Errors

  • file:FOFL0004

    If $file points to a directory.

  • file:FOFL9999

    If any other error occurs.

write-text-lines#2

declare %an:sequential function file:write-text-lines(
    $file as xs:string,
    $content as xs:string*
) as empty-sequence()

Writes a sequence of strings to a file, each followed by a platform-dependent newline character(s), using the UTF-8 character encoding.

Parameters

  • $file

    The path/URI of the file to write the content to.

  • $content

    The content to be written to the file.

Returns

  • empty-sequence()

    The empty sequence.

Errors

  • file:FOFL0004

    If $file points to a directory.

  • file:FOFL9999

    If any other error occurs.

copy-file-impl#2

declare %:private %an:sequential function file:copy-file-impl(
    $sourceFile as xs:string,
    $destination as xs:string
) as empty-sequence() external

Copies a file given a source and a destination path/URI.

Parameters

  • $sourceFile

    The path/URI of the file to copy.

  • $destination

    The destination path/URI.

Returns

  • empty-sequence()

    The empty sequence.

Errors

  • file:FOFL0001

    If the $source path does not exist.

  • file:FOFL0002

    If the computed destination points to directory.

  • file:FOFL0003

    If $destination does not exist and it's parent directory does not exist either.

  • file:FOFL0004

    If $sourceFile points to a directory.

  • file:FOFL9999

    If any other error occurs.

copy-directory-impl#2

declare %:private %an:nondeterministic %an:sequential function file:copy-directory-impl(
    $sourceDir as xs:string,
    $destination as xs:string
) as empty-sequence()

Copies a source directory recursively to a destination path/URI.

Parameters

  • $sourceDir

    The path/URI of the directory to copy.

  • $destination

    The destination path/URI.

Returns

  • empty-sequence()

    The empty sequence.

Errors

  • file:FOFL0001

    If the $source path does not exist.

  • file:FOFL0002

    If $destination points to an existing file.

  • file:FOFL0003

    If $destination does not exist and it's parent directory does not exist either.

  • file:FOFL9999

    If any other error occurs.

copy-directory#2

declare %:private %an:nondeterministic %an:sequential function file:copy-directory(
    $sourceDir as xs:string,
    $destinationDir as xs:string
) as empty-sequence()

This is an internal function that copies an entire source directory to an destination directory. The caller to this function must make sure that both the source and destination point to existing directories.

Parameters

  • $sourceDir

    The existing source directory.

  • $destinationDir

    The existing destination directory.

Returns

  • empty-sequence()

    The empty sequence.

copy-directory-content#2

declare %:private %an:nondeterministic %an:sequential function file:copy-directory-content(
    $sourceDir as xs:string,
    $destination as xs:string
) as empty-sequence()

Copies the content of a given directory to an existing destination directory.

Parameters

  • $sourceDir

    The path/URI of the directory to copy the content from.

  • $destination

    The destination directory path/URI.

Returns

  • empty-sequence()

    The empty sequence.

Errors

  • file:FOFL0001

    If the $source path does not exist.

  • file:FOFL0003

    If $destination directory does not exist.

  • file:FOFL9999

    If any other error occurs.

delete-file-impl#1

declare %:private %an:sequential function file:delete-file-impl(
    $file as xs:string
) as empty-sequence() external

Deletes a file from the file system.

Parameters

  • $file

    The path/URI of the file to delete.

Returns

  • empty-sequence()

    The empty sequence.

Errors

  • file:FOFL0001

    If the $file path does not exist.

  • file:FOFL9999

    If any other error occurs.

delete-directory-impl#1

declare %:private %an:nondeterministic %an:sequential function file:delete-directory-impl(
    $dir as xs:string
) as empty-sequence()

Deletes a directory from the file system.

Parameters

  • $dir

    The path/URI of the directory to delete.

Returns

  • empty-sequence()

    The empty sequence.

Errors

  • file:FOFL0001

    If the $dir path does not exist.

  • file:FOFL0003

    If $dir does not point to a directory.

  • file:FOFL9999

    If any other error occurs.