Changes

Jump to navigation Jump to search
16,071 bytes added ,  12:06, 6 December 2010
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..."
<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 <a href="http://expath.org/spec/file">EXPath</a> specification.</p>

==file:exists==
<table>
<tr>
<td width="90">
<b>Signatures</b>
</td>
<td>
<code>
<b>file:exists</b>($path as xs:string) as xs:boolean</code>
<br />
</td>
</tr>
<tr>
<td>
<b>Summary</b>
</td>
<td>Checks if a path exist.</td>
</tr>
<tr>
<td>
<b>Rules</b>
</td>
<td>This function checks if a path is already used in the file system. The function returns <code>true</code> if the file or directory pointed by the <code>$path</code> parameter already exists. Otherwise it returns <code>false</code>.<br />
</td>
</tr>
</table>

==file:is-directory==
<table>
<tr>
<td width="90">
<b>Signatures</b>
</td>
<td>
<code>
<b>file:is-directory</b>($path as xs:string) as xs:boolean</code>
<br />
</td>
</tr>
<tr>
<td>
<b>Summary</b>
</td>
<td>Checks if a path points to a directory.</td>
</tr>
<tr>
<td>
<b>Rules</b>
</td>
<td>This function checks if a path points to a directory. The function returns <code>true</code> if the path points to a directory. Otherwise, it returns <code>false</code>.<br />
</td>
</tr>
</table>

==file:is-file==
<table>
<tr>
<td width="90">
<b>Signatures</b>
</td>
<td>
<code>
<b>file:is-file</b>($path as xs:string) as xs:boolean</code>
<br />
</td>
</tr>
<tr>
<td>
<b>Summary</b>
</td>
<td>Checks if a path points to a file.</td>
</tr>
<tr>
<td>
<b>Rules</b>
</td>
<td>This function checks if a path points to a file. The function returns <code>true</code> if the path points to a file. Otherwise, it returns <code>false</code>.<br />
</td>
</tr>
</table>

==file:is-readable==
<table>
<tr>
<td width="90">
<b>Signatures</b>
</td>
<td>
<code>
<b>file:is-readable</b>($path as xs:string) as xs:boolean</code>
<br />
</td>
</tr>
<tr>
<td>
<b>Summary</b>
</td>
<td>Checks if a file is readable.</td>
</tr>
<tr>
<td>
<b>Rules</b>
</td>
<td>This function checks if the file pointed by <code>$path</code> is readable. The function returns <code>true</code> if the file is readable. Otherwise it returns <code>false</code>.<br />
</td>
</tr>
</table>

==file:is-writable==
<table>
<tr>
<td width="90">
<b>Signatures</b>
</td>
<td>
<code>
<b>file:is-writable</b>($path as xs:string) as xs:boolean</code>
<br />
</td>
</tr>
<tr>
<td>
<b>Summary</b>
</td>
<td>Checks if a file is writeable.</td>
</tr>
<tr>
<td>
<b>Rules</b>
</td>
<td>This function checks if the file pointed by <code>$path</code> is writeable. The function returns <code>true</code> if the file is writeable. Otherwise it returns <code>false</code>.<br />
</td>
</tr>
</table>

==file:last-modified==
<table>
<tr>
<td width="90">
<b>Signatures</b>
</td>
<td>
<code>
<b>file:last-modified</b>($path as xs:string) as xs:dateTime</code>
<br />
</td>
</tr>
<tr>
<td>
<b>Summary</b>
</td>
<td>Returns the timestamp of a path.</td>
</tr>
<tr>
<td>
<b>Rules</b>
</td>
<td>This function retrieves the timestamp of the last modification of the item pointed by the path provided by the parameter<code>$path</code>.<br />
</td>
</tr>
</table>

==file:files==
<table>
<tr>
<td width="90">
<b>Signatures</b>
</td>
<td>
<code>
<b>file:files</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*</code>
<br />
<code>
<b>file:files</b>($path as xs:string, $recursive as xs:boolean, $pattern as xs:string) as xs:string*</code>
<br />
</td>
</tr>
<tr>
<td>
<b>Summary</b>
</td>
<td>Lists files of a directory.</td>
</tr>
<tr>
<td>
<b>Rules</b>
</td>
<td>This function lists all files in a given directory. The special files "." and ".." are never returned.<br />The optional parameter <code>$recursive</code> indicates whether the search shall recurse in the subdirectories.<br />The optional parameter <code>$pattern</code> defines a pattern and if it is present, only the files, which names match the given pattern, will be returned.<br />
</td>
</tr>
<tr>
<td>
<b>Errors</b>
</td>
<td>
<b>[FOFL0003]</b> is raised if files in the given directory cannot be returned.<br />
<b>[FOFL0004]</b> is raised for an invalid file pattern.<br />
</td>
</tr>
</table>

==file:read==
<table>
<tr>
<td width="90">
<b>Signatures</b>
</td>
<td>
<code>
<b>file:read</b>($path as xs:string) as xs:string</code>
<br />
</td>
</tr>
<tr>
<td>
<b>Summary</b>
</td>
<td>Reads a file.</td>
</tr>
<tr>
<td>
<b>Rules</b>
</td>
<td>This function reads the content of the file pointed by <code>$path</code> and returns it as a string.<br />The optional parameter <code>$encoding</code> defines the encoding type of the file.<br />
</td>
</tr>
<tr>
<td>
<b>Errors</b>
</td>
<td>
<b>[FOFL0017]</b> is raised if the provided encoding is not supported.<br />
</td>
</tr>
</table>

==file:read-binary==
<table>
<tr>
<td width="90">
<b>Signatures</b>
</td>
<td>
<code>
<b>file:read-binary</b>($path as xs:string) as xs:base64Binary</code>
<br />
</td>
</tr>
<tr>
<td>
<b>Summary</b>
</td>
<td>Reads a binary file.</td>
</tr>
<tr>
<td>
<b>Rules</b>
</td>
<td>This function reads the content of the file pointed by <code>$path</code> and returns it as a string.<br />This function reads the content of the file pointed by <code>$path</code> and returns it in Base64 representation.<br />
</td>
</tr>
<tr>
<td>
<b>Errors</b>
</td>
<td>
<b>[FOFL0001]</b> is raised if the file cannot be read.<br />
</td>
</tr>
</table>

==file:size==
<table>
<tr>
<td width="90">
<b>Signatures</b>
</td>
<td>
<code>
<b>file:size</b>($path as xs:string) as xs:integer</code>
<br />
</td>
</tr>
<tr>
<td>
<b>Summary</b>
</td>
<td>Returns the file size.</td>
</tr>
<tr>
<td>
<b>Rules</b>
</td>
<td>This function returns the size, in bytes, of the file pointed by <code>$path</code>.<br />
</td>
</tr>
</table>

==file:write==
<table>
<tr>
<td width="90">
<b>Signatures</b>
</td>
<td>
<code>
<b>file:write</b>($path as xs:string, $items as xs:item()*, $params as xs:node()*) as empty-sequence()</code>
<br />
<code>
<b>file:write</b>($path as xs:string, $items as xs:item()*, $params as xs:node()*, $append as xs:boolean) as empty-sequence()</code>
<br />
</td>
</tr>
<tr>
<td>
<b>Summary</b>
</td>
<td>Writes a sequence of items to a file.</td>
</tr>
<tr>
<td>
<b>Rules</b>
</td>
<td>This function writes a sequence of <code>items</code> to a file. It either creates a new file, or appends the serialized content to the file pointed by <code>$path</code>.<br />The <code>$params</code> 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>.<br />If the <code>$append</code> flag is true and the file does not exist, a new one is created.<br />
</td>
</tr>
<tr>
<td>
<b>Errors</b>
</td>
<td>
<b>[FOFL0002]</b> is raised if the file cannot be written.<br />
<b>[FOFL0008]</b> is raised if the <code>$append</code> flag is <code>false</code> and a file with the same path already exists.<br />
</td>
</tr>
</table>

==file:write-binary==
<table>
<tr>
<td width="90">
<b>Signatures</b>
</td>
<td>
<code>
<b>file:write-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>
<br />
</td>
</tr>
<tr>
<td>
<b>Summary</b>
</td>
<td>Writes a sequence of items to a file.</td>
</tr>
<tr>
<td>
<b>Rules</b>
</td>
<td>This function writes binary data into a file. It either creates a new file or appends the content to the file pointed by <code>$path</code>.<br />If the <code>$append</code> flag is true and the file does not exist, a new one is created.<br />
</td>
</tr>
<tr>
<td>
<b>Errors</b>
</td>
<td>
<b>[FOFL0002]</b> is raised if the file cannot be written.<br />
<b>[FOFL0008]</b> is raised if the <code>$append</code> flag is <code>false</code> and a file with the same path already exists.<br />
</td>
</tr>
</table>

==file:mkdir==
<table>
<tr>
<td width="90">
<b>Signatures</b>
</td>
<td>
<code>
<b>file:mkdir</b>($path as xs:string, $recursive as xs:boolean) as empty-sequence()</code>
<br />
</td>
</tr>
<tr>
<td>
<b>Summary</b>
</td>
<td>Creates a newwdirectory.</td>
</tr>
<tr>
<td>
<b>Rules</b>
</td>
<td>This function creates a directory.<br />The optional parameter <code>$recursive</code> indicates whether parent directories are to be created recursively.<br />
</td>
</tr>
<tr>
<td>
<b>Errors</b>
</td>
<td>
<b>[FOFL0008]</b> is raised if a file with the same path already exists in the file system.<br />
<b>[FOFL0011]</b> is raised if the directory in which the new sub-directory is to be created is write protected.<br />
<b>[FOFL0012]</b> is raised if the directory cannot be created for some other reason.<br />
</td>
</tr>
</table>

==file:delete==
<table>
<tr>
<td width="90">
<b>Signatures</b>
</td>
<td>
<code>
<b>file:delete</b>($path as xs:string) as empty-sequence()</code>
<br />
<code>
<b>file:delete</b>($path as xs:string, $recursive as xs:boolean) as empty-sequence()</code>
<br />
</td>
</tr>
<tr>
<td>
<b>Summary</b>
</td>
<td>Deletes a file.</td>
</tr>
<tr>
<td>
<b>Rules</b>
</td>
<td>This function deletes a file or directory from the file system.<br />If the optional parameter <code>$recursive</code> is provided, the operation is performed recursively for all sub-directories of the given directory.<br />
</td>
</tr>
<tr>
<td>
<b>Errors</b>
</td>
<td>
<b>[FOFL0005]</b> is raised if the file/directory pointed by <code>$path</code> is write-protected and cannot be deleted.<br />
<b>[FOFL0006]</b> is raised if the file/directory pointed by <code>$path</code> does not exist.<br />
<b>[FOFL0013]</b> is raised if the file/directory pointed by <code>$path</code> cannot be deleted for some other reason.<br />
</td>
</tr>
</table>

==file:copy==
<table>
<tr>
<td width="90">
<b>Signatures</b>
</td>
<td>
<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>
<br />
</td>
</tr>
<tr>
<td>
<b>Summary</b>
</td>
<td>Copies a file.</td>
</tr>
<tr>
<td>
<b>Rules</b>
</td>
<td>This function copies a file specified by <code>$source</code> to <code>$target</code>.<br />If the optional parameter <code>$overwrite</code> is provided and evaluates to <code>true</code>, the target file, if it exists, will be overwritten.<br />
</td>
</tr>
<tr>
<td>
<b>Errors</b>
</td>
<td>
<b>[FOFL0006]</b> is raised if the file pointed by <code>$source</code> does not exist.<br />
<b>[FOFL0008]</b> is raised if the file to be copied already exists in the specified target and the <code>$overwrite</code> parameter is missing or evaluates to <code>false</code>.<br />
<b>[FOFL0016]</b> is raised if the source file cannot be copied because of some other reason.<br />
</td>
</tr>
</table>

==file:move==
<table>
<tr>
<td width="90">
<b>Signatures</b>
</td>
<td>
<code>
<b>file:move</b>($source as xs:string, $target as xs:string) as empty-sequence()</code>
<br />
</td>
</tr>
<tr>
<td>
<b>Summary</b>
</td>
<td>Moves a file.</td>
</tr>
<tr>
<td>
<b>Rules</b>
</td>
<td>This function moves/renames the file pointed by <code>$source</code> to <code>$target</code>.<br />
</td>
</tr>
<tr>
<td>
<b>Errors</b>
</td>
<td>
<b>[FOFL0006]</b> is raised if the file pointed by <code>$source</code> does not exist.<br />
<b>[FOFL0008]</b> is raised if 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 directory.<br />
<b>[FOFL0010]</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 for some other reason.<br />
</td>
</tr>
</table>

==file:path-separator==
<table>
<tr>
<td width="90">
<b>Signatures</b>
</td>
<td>
<code>
<b>file:path-separator</b>() as xs:string</code>
<br />
</td>
</tr>
<tr>
<td>
<b>Summary</b>
</td>
<td>Returns the path separator.</td>
</tr>
<tr>
<td>
<b>Rules</b>
</td>
<td>This function returns the path separator used by the operating system.<br />
</td>
</tr>
</table>

==file:path-to-full-path==
<table>
<tr>
<td width="90">
<b>Signatures</b>
</td>
<td>
<code>
<b>file:path-to-full-path</b>($path as xs:string) as xs:string</code>
<br />
</td>
</tr>
<tr>
<td>
<b>Summary</b>
</td>
<td>Returns a full path representation.</td>
</tr>
<tr>
<td>
<b>Rules</b>
</td>
<td>This function transforms a path into a full operating system path.<br />
</td>
</tr>
</table>

==file:path-to-uri==
<table>
<tr>
<td width="90">
<b>Signatures</b>
</td>
<td>
<code>
<b>file:path-to-uri</b>($path as xs:string) as xs:string</code>
<br />
</td>
</tr>
<tr>
<td>
<b>Summary</b>
</td>
<td>Returns a URI representation.</td>
</tr>
<tr>
<td>
<b>Rules</b>
</td>
<td>This function transforms a file system path into a URI with the file:// scheme.<br />
</td>
</tr>
</table>
Anonymous user

Navigation menu