This module contains [[Querying#Functions|XQuery Functions]] to perform file system related operations, such as listing, reading, or writing files. All functions are preceded by the <code>file:</code> prefix, which is linked to the <code>www.basexhttp://expath.org/ns/file</code> namespace. This module might be has been aligned with the latest [http://expath.org/spec/file EXPath File Module] draftfrom 2011 (expected to be online in a few days). <font color="orange">BaseX 6.6.2</font> ==file:directory-separator=={||-| valign='top' width='90' | '''Signatures'''|<code><b>file:directory-separator</b> as xs:string</code><br />|-| valign='top' | '''Summary'''|Returns the directory separator.|-| valign='top' | '''Rules'''|This variable returns the directory separator used by the operating system, such as "/" or "\".<br />|} ==file:path-separator=={||-| valign='top' width='90' | '''Signatures'''|<code><b>file:path-separator</b> as xs:string</code><br />|-| valign='top' | '''Summary'''|Returns the path separator.|-| valign='top' | '''Rules'''|This variable returns the path separator used by the operating system, such as ";" or ":".<br />|}
==file:exists==
|}
==file:islast-readablemodified==
{|
|-
| valign='top' width='90' | '''Signatures'''
|<code><b>file:islast-readablemodified</b>($path as xs:string) as xs:booleandateTime</code><br />
|-
| valign='top' | '''Summary'''
|Checks if Returns the timestamp of a file is readablepath.
|-
| valign='top' | '''Rules'''
|This function returns an <code>xs:boolean</code> indicating whether retrieves the timestamp of the last modification of the file or directory specified by <code>$path</code> exists and .<br />|-| valign='top' | '''Errors'''|<b>[[XQuery Errors#File Functions Errors (FOFL)|FOFL0001]]</b> is readableraised if the specified path does not exist.<br />
|}
==file:is-writablesize==
{|
|-
| valign='top' width='90' | '''Signatures'''
|<code><b>file:is-writablesize</b>($path file as xs:string) as xs:booleaninteger</code><br />
|-
| valign='top' | '''Summary'''
|Checks Returns the size of a file.|-| valign='top' | '''Rules'''|This function returns the size, in bytes, of the file specified by <code>$path</code>.<br />|-| valign='top' | '''Errors'''|<b>[[XQuery Errors#File Functions Errors (FOFL)|FOFL0001]]</b> is raised if the specified path does not exist.<br /><b>[[XQuery Errors#File Functions Errors (FOFL)|FOFL0004]]</b> is raised if the specified path does not point to a file .<br />|} ==file:base-name=={||-| valign='top' width='90' | '''Signatures'''|<code><b>file:base-name</b>($path as xs:string) as xs:integer</code><br /><code><b>file:base-name</b>($path as xs:string, $suffix as xs:string) as xs:integer</code><br />|-| valign='top' | '''Summary'''|Returns the base-name of a path.|-| valign='top' | '''Rules'''|This function returns the base-name of the path specified by <code>$path</code>, which is writablethe component after the last directory separator.<br /> If <code>$suffix</code> is specified, it will be trimmed from the end of the result.<br />|} ==file:dir-name=={||-| valign='top' width='90' | '''Signatures'''|<code><b>file:dir-name</b>($path as xs:string) as xs:integer</code><br />|-| valign='top' | '''Summary'''|Returns the parent directory of a path.
|-
| valign='top' | '''Rules'''
|This function returns an <code>xs:boolean</code> indicating whether the file parent directory of the path specified by <code>$path</code> exists and , which is writablethe component before the last directory separator.<br />
|}
==file:lastpath-modifiedto-native==
{|
|-
| valign='top' width='90' | '''Signatures'''
|<code><b>file:lastpath-modifiedto-native</b>($path as xs:string) as xs:dateTimestring</code><br />
|-
| valign='top' | '''Summary'''
|Returns the timestamp of a native pathrepresentation.
|-
| valign='top' | '''Rules'''
|This function retrieves transforms the timestamp of the last modification of the file or directory specified by <code>$path</code>argument to its native representation on the operating system.<br />
|-
| valign='top' | '''Errors'''
|<b>[[XQuery Errors#File Functions Errors (FOFL)|FOFL0001FOFL0000]]</b> is raised if the specified path does not existcannot be transformed to its native representation.<br />
|}
==file:sizeresolve-path==
{|
|-
| valign='top' width='90' | '''Signatures'''
|<code><b>file:sizeresolve-path</b>($path as xs:string) as xs:integerstring</code><br />
|-
| valign='top' | '''Summary'''
|Returns the size of a filefull path representation.
|-
| valign='top' | '''Rules'''
|This function returns transforms the size, in bytes, of the file specified by <code>$path</code>. The return value is unspecified if the argument points to a directoryan absolute operating system path.<br />|} ==file:path-to-uri=={||-| valign='top' width='90' | '''Signatures'''|<code><b>file:path-to-uri</b>($path as xs:string) as xs:string</code><br />|-| valign='top' | '''Summary'''|Returns a URI representation.
|-
| valign='top' | '''ErrorsRules'''|This function transforms the path specified by <bcode>[[XQuery Errors#File Functions Errors (FOFL)|FOFL0001]]$path</bcode> is raised if into a URI with the specified path does not exist<code>file://</code> scheme.<br />
|}
|-
| 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>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 />
|-
| valign='top' | '''Summary'''
|-
| valign='top' | '''Rules'''
|This function writes a sequence, specified by <code>$items</code>, to a file specified by <code>$path</code>. If the specified file already exists, it will be overwritten.<br />The optional argument <code>$params</code> is used to set the serialization parameters (see [[Serialization]] for more details).<br />If the <code>$append</code> flag is set to <code>true</code>, the serialized items are appended to the original file. If the file does not exist, a new one is created.<br />
|-
| valign='top' | '''Errors'''
|-
| valign='top' width='90' | '''Signatures'''
|<code><b>file:write-binary</b>($path as xs:string, $item as xs:base64Binary) as empty-sequence()</code><br /><code><b>file:write-binary</b>($path as xs:string, $item as xs:base64Binary, $append as xs:boolean) as empty-sequence()</code><br />
|-
| valign='top' | '''Summary'''
|-
| valign='top' | '''Rules'''
|This function writes a <code>xs:basex64Binary</code> item specified by <code>$item</code> to a file specified by <code>$path</code>. If the specified file already exists, it will be overwritten.<br />If the <code>$append</code> flag is set to <code>true</code>, the serialized item is appended to the original file. If the file does not exist, a new one is created.<br />
|-
| valign='top' | '''Errors'''
|}
==file:copyappend==
{|
|-
| valign='top' width='90' | '''Signatures'''
|<code><b>file:copyappend</b>($source path as xs:string, $target items as xs:item()*) as empty-sequence()</code><br /><code><b>file:append</b>($path as xs:string, $items as xs:item()*, $params as xs:node()*) as empty-sequence()</code><br />
|-
| valign='top' | '''Summary'''
|Copies Appends a sequence of items to a file.
|-
| valign='top' | '''Rules'''
|This function copies appends a file specified by sequence of <code>$sourceitems</code> , to the a file or directory specified by <code>$targetpath</code>. If the target represents an existing specified filedoes not exists, it will be overwritten. No operation will be performed if the source and target path are equala new file is created.<br />
|-
| valign='top' | '''Errors'''
|<b>[[XQuery Errors#File Functions Errors (FOFL)|FOFL0001]]</b> is raised if the specified source does not exist.<br /><b>[[XQuery Errors#File Functions Errors (FOFL)|FOFL0004]]</b> is raised if the specified source is a directory.<br /><b>[[XQuery Errors#File Functions Errors (FOFL)|FOFL0006]]</b> path is raised if the specified target path points to a file in a non-existing directory.<br /><b>[[XQuery Errors#File Functions Errors (FOFL)|FOFL0008]]</b> is raised if the operation fails for some other reason.<br />
|}
==file:moveappend-binary==
{|
|-
| valign='top' width='90' | '''Signatures'''
|<code><b>file:moveappend-binary</b>($source path as xs:string, $target item as xs:stringbase64Binary) as empty-sequence()</code><br />
|-
| valign='top' | '''Summary'''
|Moves Writes a sequence of items to a file.
|-
| valign='top' | '''Rules'''
|This function moves, or renames, the file or directory specified by appends a sequence of <code>xs:basex64Binary</code> <code>$sourceitems</code> , to the path a file specified by <code>$targetpath</code>. No operation will be performed if If the source and target path are equalspecified file does not exists, a new file is created.<br />
|-
| valign='top' | '''Errors'''
|<b>[[XQuery Errors#File Functions Errors (FOFL)|FOFL0001FOFL0004]]</b> is raised if the specified source does not exist.<br /><b>[[XQuery Errors#File Functions Errors (FOFL)|FOFL0006]]</b> path is raised if the specified target path points to a file in a non-existing directory.<br /><b>[[XQuery Errors#File Functions Errors (FOFL)|FOFL0008]]</b> is raised if the operation fails for some other reason.<br />
|}
==file:path-separatorcopy==
{|
|-
| valign='top' width='90' | '''Signatures'''
|<code><b>file:path-separatorcopy</b>() $source as xs:string, $target as xs:string) as empty-sequence()</code><br />
|-
| valign='top' | '''Summary'''
|Returns the path separatorCopies a file.
|-
| valign='top' | '''Rules'''
|This function returns copies a file specified by <code>$source</code> to the file or directory specified by <code>$target</code>. If the target represents an existing file, it will be overwritten. No operation will be performed if the source and target path separator used by are equal.<br />|-| valign='top' | '''Errors'''|<b>[[XQuery Errors#File Functions Errors (FOFL)|FOFL0001]]</b> is raised if the specified source does not exist.<br /><b>[[XQuery Errors#File Functions Errors (FOFL)|FOFL0004]]</b> is raised if the specified source is a directory.<br /><b>[[XQuery Errors#File Functions Errors (FOFL)|FOFL0006]]</b> is raised if the specified target path points to a file in a non-existing directory.<br /><b>[[XQuery Errors#File Functions Errors (FOFL)|FOFL0008]]</b> is raised if the operating systemoperation fails for some other reason.<br />
|}
==file:path-to-full-pathmove==
{|
|-
| valign='top' width='90' | '''Signatures'''
|<code><b>file:path-to-full-pathmove</b>($path source as xs:string) , $target as xs:string) as empty-sequence()</code><br />
|-
| valign='top' | '''Summary'''
|Returns Moves a full path representationfile.
|-
| valign='top' | '''Rules'''
|This function transforms moves, or renames, the file or directory specified by <code>$source</code> to the path specified by <code>$pathtarget</code> into a full operating system . No operation will be performed if the source and target pathare equal.<br />|} ==file:path-to-uri=={|
|-
| valign='top' width='90' | '''SignaturesErrors'''|<codeb>[[XQuery Errors#File Functions Errors (FOFL)|FOFL0001]]</b>file:path-to-uriis raised if the specified source does not exist.<br /><b>[[XQuery Errors#File Functions Errors ($path as xs:stringFOFL) as xs:string|FOFL0006]]</code><br /b>|-| valign='top' | '''Summary'''|Returns a URI representation.|-| valign='top' | '''Rules'''|This function transforms is raised if the path specified by <code>$target pathpoints to a file in a non-existing directory.<br /code> into a URI with the <codeb>file://[[XQuery Errors#File Functions Errors (FOFL)|FOFL0008]]</codeb> schemeis raised if the operation fails for some other reason.<br />
|}
[[Category:XQuery]]