Changes

Jump to navigation Jump to search
1,600 bytes added ,  20:57, 13 December 2010
based on docs2wiki.xq
<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>file:</code> prefix. Some changes might happen to this module, as it is currently aligned with the upcoming [http://expath.org/spec/file EXPath] specification.</p>
==file:exists==
 
{|
|-
| valign='top' width="'90" ' | '''Signatures'''|<code>'''<b>file:exists'''</b>($path as xs:string) as xs:boolean</code><br />
|-
| valign='top' | '''Summary'''| Checks if a path exist.
|-
| valign='top' | '''Rules'''| This function checks if a path is already used in the file system. The function returns an <code>truexs:boolean</code> if the indicating whether a file or directory pointed specified by the <code>$path</code> parameter already existsin the file system. Otherwise it returns <code>false<br /code>.
|}
==file:is-directory==
 
{|
|-
| valign='top' width="'90" ' | <b>'''Signatures</b>'''|<code><b>file:is-directory</b>($path as xs:string) as xs:boolean</code><br />
|-
| <b>valign='top' | '''Summary</b>'''| Checks if a path points to a directory.
|-
| <b>valign='top' | '''Rules</b>'''| This function checks if a path points to a directory. The function returns an <code>truexs:boolean</code> if indicating whether the path points to a directory. Otherwise, it returns argument <code>false$path</code>points to an existing directory.<br />
|}
==file:is-file==
 
{|
|-
| valign='top' width="'90" ' | <b>'''Signatures</b>'''|<code><b>file:is-file</b>($path as xs:string) as xs:boolean</code><br />
|-
| <b>valign='top' | '''Summary</b>'''| Checks if a path points to a file.
|-
| <b>valign='top' | '''Rules</b>'''| This function checks if a path points to a file. The function returns an <code>truexs:boolean</code> if indicating whether the path points to a file. Otherwise, it returns argument <code>false$path</code>points to an existing file.<br /> |}
==file:is-readable==
 
{|
|-
| valign='top' width="'90" ' | <b>'''Signatures</b>'''|<code><b>file:is-readable</b>($path as xs:string) as xs:boolean</code><br />
|-
| <b>valign='top' | '''Summary</b>'''| Checks if a file is readable.
|-
| <b>valign='top' | '''Rules</b>'''| This function checks if the file pointed by <code>$path</code> is readable. The function returns an <code>truexs:boolean</code> if indicating whether the file is readable. Otherwise it returns specified by <code>false$path</code>exists and is readable.<br />
|}
==file:is-writable==
 
{|
|-
| valign='top' width="'90" ' | <b>'''Signatures</b>'''|<code><b>file:is-writable</b>($path as xs:string) as xs:boolean</code><br />
|-
| <b>valign='top' | '''Summary</b>'''| Checks if a file is writeablewritable.
|-
| <b>valign='top' | '''Rules</b>'''| This function checks if the file pointed by <code>$path</code> is writeable. The function returns an <code>truexs:boolean</code> if indicating whether the file is writeable. Otherwise it returns specified by <code>false$path</code>exists and is writable.<br />
|}
==file:last-modified==
 
{|
|-
| valign='top' width="'90" ' | <b>'''Signatures</b>'''|<code><b>file:last-modified</b>($path as xs:string) as xs:dateTime</code><br />
|-
| <b>valign='top' | '''Summary</b>'''| Returns the timestamp of a path.
|-
| <b>valign='top' | '''Rules</b>'''| This function retrieves the timestamp of the last modification of the item pointed file or directory specified by the path provided by the parameter<code>$path</code>.<br />|} - | valign='top' | '''Errors'''==file:files==|<b>[FOFL0001]</b> is raised if the specified path does not exist.<br />|}
==file:size==
{|
|-
| valign='top' width="'90" ' | <b>'''Signatures</b>'''|<code><b>file:filessize</b>($path as xs:string) as xs:string*</code> <br /> <code><b>file:files</b>($path as xs:string, $recursive as xs:boolean) as xs:string*integer</code> <br /> <code><b>file:files</b>($path as xs:string, $recursive as xs:boolean, $pattern as xs:string) as xs:string*</code>
|-
| <b>valign='top' | '''Summary</b>'''| Lists files Returns the size of a directoryfile.
|-
| <b>valign='top' | '''Rules</b>'''| This function lists all files returns the size, in a given directory. The special files "." and ".." are never returned.<br />The optional parameter bytes, of the file specified by <code>$recursivepath</code> indicates whether the search shall recurse in the subdirectories.<br />The optional parameter <code>$pattern</code> defines a pattern and return value is unspecified if it is present, only the files, which names match the given pattern, will be returnedargument points to a directory.<br />
|-
| <b>valign='top' | '''Errors</b>'''| <b>[FOFL0003FOFL0001]</b> is raised if files in the given directory cannot be returned.<br /> <b>[FOFL0004]</b> is raised for an invalid file patternspecified path does not exist.<br /> |} ==file:read==
==file:list==
{|
|-
| valign='top' width="'90" ' | '''Signatures'''|<code><b>file:list</b>Signatures($path as xs:string) as xs:string*</code><br /><code><b>file:list</b>|($path as xs:string, $recursive as xs:boolean) as xs:string*</code><br /><code><b>file:readlist</b>($path as xs:string, $recursive as xs:boolean, $pattern as xs:string) as xs:string*</code><br />
|-
| <b>valign='top' | '''Summary</b>'''| Reads Lists the contents of a filedirectory.
|-
| <b>valign='top' | '''Rules</b>'''| This function reads the content of lists all files and directories found in the file pointed directory that is specified by <code>$path</code> and returns it . The returned paths are relative to the provided path.<br />The optional parameter <code>$recursive</code> specifies whether the sub-directories are to be recursed as a stringwell.<br />The optional parameter <code>$encodingpattern</code> defines a file name pattern. If present, only those files and directories are returned that correspond to the encoding type of the filepattern. A pattern may contain asterisks (<code>*</code>) to match zero or more characters, and question marks (<code>?</code>) to match single characters. Several patterns can be separated with a comma (<code>,</code>).<br />
|-
| valign='top' | '''Errors'''| <b>Errors[FOFL0001]</b>| is raised if the specified path does not exist.<br /><b>[FOFL0017FOFL0003]</b> is raised if the provided encoding specified path does not point to a directory.<br /><b>[FOFL0008]</b> is not supportedraised if the operation fails for some other reason.<br />|} ==file:read-binary==
==file:create-directory==
{|
|-
| valign='top' width="'90" ' | <b>'''Signatures</b>'''|<code><b>file:readcreate-binarydirectory</b>($path as xs:string) as xs:base64Binaryempty-sequence()</code><br />
|-
| <b>valign='top' | '''Summary</b>'''| Reads Creates a binary filenew directory path.
|-
| <b>valign='top' | '''Rules</b>'''| This function reads the content of recursively creates the file pointed directories specified by <code>$path</code> and returns it in Base64 representation.<br />
|-
| valign='top' | '''Errors'''|<b>[FOFL0002]</b>Errorsis raised if a file with the same path already exists.<br /><b>[FOFL0006]</b>| is raised if the specified path is invalid (e.g., contains invalid characters).<br /><b>[FOFL0001FOFL0008]</b> is raised if the file cannot be readoperation fails for some other reason.<br />
|}
==file:size==
==file:delete==
{|
|-
| valign='top' width="'90" ' | '''Signatures'''|<code><b>Signaturesfile:delete</b>|($path as xs:string) as empty-sequence()</code><br /><code><b>file:sizedelete</b>($path as xs:string) , $recursive as xs:integerboolean) as empty-sequence()</code><br />
|-
| <b>valign='top' | '''Summary</b>'''| Returns the Deletes a file sizeor directory.
|-
| <b>valign='top' | '''Rules</b>'''| This function returns the size, in bytes, of the deletes a file pointed or directory specified by <code>$path</code>. No operation will be performed if the specified path does not exist.<br />If the optional parameter <code>$recursive</code> is provided, the operation is performed recursively for all sub-directories of the given path.<br />
|-
| valign='top' | '''Errors'''| <b>Errors[FOFL0005]</b>| is raised if <code>$recursive</code> is not specified or set to <code>false</code>, and if the specified path points to a non-empty directory.<br /><b>[FOFL0001FOFL0008]</b> is raised if the file cannot be readoperation fails for some other reason.<br />
|}
==file:write==
==file:read==
{|
|-
| valign='top' width="'90" ' | <b>'''Signatures</b>'''|<code><b>file:writeread</b>($path as xs:string, $items as xs:item()*, $params as xs:node()*) as empty-sequence()string</code> <br /><code><b>file:writeread</b>($path as xs:string, $items encoding as xs:item(string)*, $params as xs:node()*, $append as xs:boolean) as empty-sequence()string</code> <br />
|-
| <b>valign='top' | '''Summary</b>'''| Writes a sequence of items to Reads the contents a file.
|-
| <b>valign='top' | '''Rules</b>'''| This function writes a sequence reads the textual contents of <code>items</code> to a file. It either creates a new file, or appends the serialized content to the file pointed specified by <code>$path</code>.<br />The and returns it as a <code>$paramsxs:string</code> parameter is used to set the serialization parameters as defined in [http://www.w3.org/TR/xslt-xquery-serialization XSLT 2.0 and XQuery 1.0 Serialization].<br />If the The optional parameter <code>$appendencoding</code> flag is true and defines the encoding of the file does not exist, a new one is created.<br />
|-
| valign='top' | '''Errors'''| <b>Errors[FOFL0001]</b>| is raised if the specified file does not exist.<br /><b>[FOFL0002FOFL0004]</b> is raised if the file cannot be writtenspecified path is a directory.<br /><b>[FOFL0008FOFL0007]</b> is raised if the specified encoding is not supported, or unknown.<code>$append<br /code> flag is <codeb>false[FOFL0008]</codeb> and a file with is raised if the same path already existsoperation fails for some other reason.<br />
|}
==file:write-binary==
==file:read-binary==
{|
|-
| valign='top' width="'90" ' | <b>'''Signatures</b>'''|<code><b>file:writeread-binary</b>($path as xs:string, $items ) as xs:base64Binary) as empty-sequence()</code> <br /><code><b>file:write-binary</b>($path as xs:string, $items as xs:base64Binary, $append as xs:boolean) as empty-sequence()</code>
|-
| <b>valign='top' | '''Summary</b>'''| Writes a sequence Reads the binary contents of items to a file.
|-
| <b>valign='top' | '''Rules</b>'''| This function writes reads the binary data into a file. It either creates a new file or appends the content to of the file pointed specified by <code>$path</code>.<br />If the and returns as a <code>$appendxs:base64Binary</code> flag is true and the file does not exist, a new one is created.<br />
|-
| <b>valign='top' | '''Errors</b>'''| <b>[FOFL0002FOFL0001]</b> is raised if the specified file cannot be writtendoes not exist.<br /><b>[FOFL0008FOFL0004]</b> is raised if the specified path is a directory.<code>$append<br /code> flag is <codeb>false[FOFL0008]</codeb> and a file with is raised if the same path already existsoperation fails for some other reason.<br />
|}
==file:mkdir==
==file:write==
{|
|-
| valign='top' width="'90" ' | '''Signatures'''| <code><b>file:write</b>($path as xs:string, $items as xs:item()*) as empty-sequence()</code><br /><code><b>Signaturesfile:write</b>|($path as xs:string, $items as xs:item()*, $params as xs:node()*) as empty-sequence()</code><br /><code><b>file:mkdirwrite</b>($path as xs:string, $recursive items as xs:item()*, $params as xs:node()*, $append as xs:boolean) as empty-sequence()</code><br />
|-
| <b>valign='top' | '''Summary</b>'''| Creates Writes a sequence of items to a new directoryfile.
|-
| valign='top' | '''Rules'''|This function writes a sequence, specified by <bcode>Rules$items</bcode>| This function creates , to a directoryfile specified by <code>$path</code>. If the specified file already exists, it will be overwritten.<br />The optional parameter argument <code>$params</code> is used to set the serialization parameters, as defined in [http://www.w3.org/TR/xslt-xquery-serialization/ XSLT 2.0 and XQuery 1.0 Serialization].<br />If the <code>$recursiveappend</code> indicates whether parent directories flag is set to <code>true</code>, the serialized items are appended to be the original file. If the file does not exist, a new one is created recursively.<br />
|-
| <b>valign='top' | '''Errors</b>'''| <b>[FOFL0008FOFL0004]</b> is raised if a file with the same specified path already exists in the file system.<br /><b>[FOFL0011]</b> is raised if the directory in which the new sub-a directory is to be created is write protected.<br /> <b>[FOFL0012FOFL0008]</b> is raised if the directory cannot be created operation fails for some other reason.<br />
|}
==file:delete==
==file:write-binary==
{|
|-
| valign='top' width="'90" ' | <b>'''Signatures</b>'''|<code><b>file:deletewrite-binary</b>($path as xs:string, $item as xs:base64Binary) as empty-sequence()</code><br /><code><b>file:deletewrite-binary</b>($path as xs:string, $recursive item as xs:base64Binary, $append as xs:boolean) as empty-sequence()</code><br />
|-
| <b>valign='top' | '''Summary</b>'''| Deletes Writes a sequence of items to a file.
|-
| valign='top' | '''Rules'''|This function writes a <code>xs:basex64Binary</code> item specified by <bcode>Rules$item</bcode>| This function deletes to a file or directory from specified by <code>$path</code>. If the specified file systemalready exists, it will be overwritten.<br />If the optional parameter <code>$recursiveappend</code> flag is providedset to <code>true</code>, the operation serialized item is performed recursively for all sub-directories of appended to the original file. If the given directoryfile does not exist, a new one is created.<br />
|-
| <b>valign='top' | '''Errors</b>'''| <b>[FOFL0005FOFL0004]</b> is raised if the file/directory pointed by <code>$specified path</code> is write-protected and cannot be deleted.<br /> <b>[FOFL0006]</b> is raised if the file/a directory pointed by <code>$path</code> does not exist.<br /> <b>[FOFL0013FOFL0008]</b> is raised if the file/directory pointed by <code>$path</code> cannot be deleted operation fails for some other reason.<br />
|}
==file:copy==
 
{|
|-
| valign='top' width="'90" ' | <b>'''Signatures</b>'''|<code><b>file:copy</b>($source as xs:string, $target as xs:string) as empty-sequence()</code><br /><code><b>file:copy</b>($source as xs:string, $target as xs:string, $overwrite as xs:boolean) as empty-sequence()</code>
|-
| <b>valign='top' | '''Summary</b>'''| Copies a file.
|-
| <b>valign='top' | '''Rules</b>'''| This function copies a file specified by <code>$source</code> to the file or directory specified by <code>$target</code>.<br />If the optional parameter <code>$overwrite</code> is provided and evaluates to <code>true</code>, the target represents an existing file, if it exists, will be overwritten. No operation will be performed if the source and target path are equal.<br />
|-
| <b>valign='top' | '''Errors</b>'''| <b>[FOFL0006FOFL0001]</b> is raised if the file pointed by <code>$specified source</code> does not exist.<br /> <b>[FOFL0008FOFL0004]</b> is raised if the file to be copied already exists in the specified target and the <code>$overwritesource is a directory.<br /code> parameter is missing or evaluates to <codeb>false[FOFL0006]</codeb>is raised if the specified target path points to a file in a non-existing directory.<br /> <b>[FOFL0016FOFL0008]</b> is raised if the source file cannot be copied because of operation fails for some other reason.<br />
|}
==file:move==
 
{|
|-
| valign='top' width="'90" ' | <b>'''Signatures</b>'''|<code><b>file:move</b>($source as xs:string, $target as xs:string) as empty-sequence()</code><br />
|-
| <b>valign='top' | '''Summary</b>'''| Moves a file.
|-
| <b>valign='top' | '''Rules</b>'''| This function moves/, or renames , the file pointed or directory specified by <code>$source</code> to the path specified by <code>$target</code>. No operation will be performed if the source and target path are equal.<br />
|-
| <b>valign='top' | '''Errors</b>'''| <b>[FOFL0006FOFL0001]</b> is raised if the file pointed by <code>$specified source</code> does not exist.<br /> <b>[FOFL0008FOFL0006]</b> is raised if the specified target path points to a file/directory with the same name already exists in the given target.<br /> <b>[FOFL0009]</b> is raised if the item pointed by <code>$source</code> is a non-existing directory.<br /> <b>[FOFL0010FOFL0008]</b> is raised if the file pointed by <code>$source</code> is write-protected and cannot be moved.<br /> <b>[FOFL0014]</b> is raised if the file cannot be moved operation fails for some other reason.<br /> |}
==file:path-separator==
 
{|
|-
| valign='top' width="'90" ' | <b>'''Signatures</b>'''|<code><b>file:path-separator</b>() as xs:string</code> <br />
|-
| <b>valign='top' | '''Summary</b>'''| Returns the path separator.
|-
| <b>valign='top' | '''Rules</b>'''| This function returns the path separator used by the operating system.<br />|}
==file:path-to-full-path==
 
{|
|-
| valign='top' width="'90" ' | <b>'''Signatures</b>'''|<code><b>file:path-to-full-path</b>($path as xs:string) as xs:string</code><br />
|-
| <b>valign='top' | '''Summary</b>'''| Returns a full path representation.
|-
| <b>valign='top' | '''Rules</b>'''| This function transforms a the path specified by <code>$path </code> into a full operating system path.<br />|}
==file:path-to-uri==
 
{|
|-
| valign='top' width="'90" ' | <b>'''Signatures</b>'''|<code><b>file:path-to-uri</b>($path as xs:string) as xs:string</code><br />
|-
| <b>valign='top' | '''Summary</b>'''| Returns an a URI representation.
|-
| <b>valign='top' | '''Rules</b>'''| This function transforms a file system the path specified by <code>$path </code> into an a URI with the <code>file:// </code> scheme.<br />
|}
 
[[Category:XQuery]]
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu