Difference between revisions of "File Module"
Jump to navigation
Jump to search
(Created page with "<p>The file module contains extension functions to perform file system related operations, such as listing, reading, or writing files. All functions are preceded by the <code>fil...") |
|||
Line 616: | Line 616: | ||
</tr> | </tr> | ||
</table> | </table> | ||
+ | [[Category:XQuery]] | ||
+ | [[Category:Wikify]] |
Revision as of 18:03, 9 December 2010
The file module contains extension functions to perform file system related operations, such as listing, reading, or writing files. All functions are preceded by the file:
prefix. Some changes might happen to this module, as it is currently aligned with the upcoming <a href="http://expath.org/spec/file">EXPath</a> specification.
Contents
- 1 file:exists
- 2 file:is-directory
- 3 file:is-file
- 4 file:is-readable
- 5 file:is-writable
- 6 file:last-modified
- 7 file:files
- 8 file:read
- 9 file:read-binary
- 10 file:size
- 11 file:write
- 12 file:write-binary
- 13 file:mkdir
- 14 file:delete
- 15 file:copy
- 16 file:move
- 17 file:path-separator
- 18 file:path-to-full-path
- 19 file:path-to-uri
file:exists
Signatures |
|
Summary |
Checks if a path exist. |
Rules |
This function checks if a path is already used in the file system. The function returns true if the file or directory pointed by the $path parameter already exists. Otherwise it returns false . |
file:is-directory
Signatures |
|
Summary |
Checks if a path points to a directory. |
Rules |
This function checks if a path points to a directory. The function returns true if the path points to a directory. Otherwise, it returns false . |
file:is-file
Signatures |
|
Summary |
Checks if a path points to a file. |
Rules |
This function checks if a path points to a file. The function returns true if the path points to a file. Otherwise, it returns false . |
file:is-readable
Signatures |
|
Summary |
Checks if a file is readable. |
Rules |
This function checks if the file pointed by $path is readable. The function returns true if the file is readable. Otherwise it returns false . |
file:is-writable
Signatures |
|
Summary |
Checks if a file is writeable. |
Rules |
This function checks if the file pointed by $path is writeable. The function returns true if the file is writeable. Otherwise it returns false . |
file:last-modified
Signatures |
|
Summary |
Returns the timestamp of a path. |
Rules |
This function retrieves the timestamp of the last modification of the item pointed by the path provided by the parameter$path . |
file:files
Signatures |
|
Summary |
Lists files of a directory. |
Rules |
This function lists all files in a given directory. The special files "." and ".." are never returned. The optional parameter $recursive indicates whether the search shall recurse in the subdirectories.The optional parameter $pattern defines a pattern and if it is present, only the files, which names match the given pattern, will be returned. |
Errors |
[FOFL0003] is raised if files in the given directory cannot be returned. |
file:read
Signatures |
|
Summary |
Reads a file. |
Rules |
This function reads the content of the file pointed by $path and returns it as a string.The optional parameter $encoding defines the encoding type of the file. |
Errors |
[FOFL0017] is raised if the provided encoding is not supported. |
file:read-binary
Signatures |
|
Summary |
Reads a binary file. |
Rules |
This function reads the content of the file pointed by $path and returns it as a string.This function reads the content of the file pointed by $path and returns it in Base64 representation. |
Errors |
[FOFL0001] is raised if the file cannot be read. |
file:size
Signatures |
|
Summary |
Returns the file size. |
Rules |
This function returns the size, in bytes, of the file pointed by $path . |
file:write
Signatures |
|
Summary |
Writes a sequence of items to a file. |
Rules |
This function writes a sequence of items to a file. It either creates a new file, or appends the serialized content to the file pointed by $path .The $params parameter is used to set the serialization parameters as defined in <a href="http://www.w3.org/TR/xslt-xquery-serialization/">XSLT 2.0 and XQuery 1.0 Serialization</a>.If the $append flag is true and the file does not exist, a new one is created. |
Errors |
[FOFL0002] is raised if the file cannot be written. |
file:write-binary
Signatures |
|
Summary |
Writes a sequence of items to a file. |
Rules |
This function writes binary data into a file. It either creates a new file or appends the content to the file pointed by $path .If the $append flag is true and the file does not exist, a new one is created. |
Errors |
[FOFL0002] is raised if the file cannot be written. |
file:mkdir
Signatures |
|
Summary |
Creates a newwdirectory. |
Rules |
This function creates a directory. The optional parameter $recursive indicates whether parent directories are to be created recursively. |
Errors |
[FOFL0008] is raised if a file with the same path already exists in the file system. |
file:delete
Signatures |
|
Summary |
Deletes a file. |
Rules |
This function deletes a file or directory from the file system. If the optional parameter $recursive is provided, the operation is performed recursively for all sub-directories of the given directory. |
Errors |
[FOFL0005] is raised if the file/directory pointed by |
file:copy
Signatures |
|
Summary |
Copies a file. |
Rules |
This function copies a file specified by $source to $target .If the optional parameter $overwrite is provided and evaluates to true , the target file, if it exists, will be overwritten. |
Errors |
[FOFL0006] is raised if the file pointed by |
file:move
Signatures |
|
Summary |
Moves a file. |
Rules |
This function moves/renames the file pointed by $source to $target . |
Errors |
[FOFL0006] is raised if the file pointed by |
file:path-separator
Signatures |
|
Summary |
Returns the path separator. |
Rules |
This function returns the path separator used by the operating system. |
file:path-to-full-path
Signatures |
|
Summary |
Returns a full path representation. |
Rules |
This function transforms a path into a full operating system path. |
file:path-to-uri
Signatures |
|
Summary |
Returns a URI representation. |
Rules |
This function transforms a file system path into a URI with the file:// scheme. |