Changes

Jump to navigation Jump to search
67 bytes added ,  06:46, 29 November 2019
=Conventions=
 
{{Mark|Updated with Version 9.0}}:
All functions and errors in this module are assigned to the <code><nowiki>http://basex.org/modules/archive</nowiki></code> namespace, which is statically bound to the {{Code|archive}} prefix.<br/>
|-
| width='120' | '''Signatures'''
|{{Func|archive:create|$entries as item(), $contents as item()*|xs:base64Binary}}<br />{{Func|archive:create|$entries as item(), $contents as item()*, $options as map(xs:string, xs:string*)?|xs:base64Binary}}<br />
|-
| '''Summary'''
|-
| '''Errors'''
|{{Error|number|#Errors}} the number of entries and contents differs.<br />{{Error|format|#Errors}} the specified option or its value is invalid or not supported.<br />{{Error|descriptor|#Errors}} entry descriptors contain invalid entry names, timestamps or compression levels.<br/>{{Error|encode|#Errors}} the specified encoding is invalid or not supported, or the string conversion failed. Invalid XML characters will be ignored if the <code>[[Options#CHECKSTRINGS{{Option|CHECKSTRINGS]]</code> option }} is turned off.<br/>{{Error|single|#Errors}} the chosen archive format only allows single entries.<br />{{Error|failerror|#Errors}} archive creation failed for some other reason.
|-
| '''Examples'''
let $path := 'audio/'
let $files := file:list($path, true(), '*.mp3')
let $zip := archive:create( $files ! element archive:entry { . }, for $file in $files ! return file:read-binary($path || .$file))
return file:write-binary('mp3.zip', $zip)</pre>
|}
|-
| width='120' | '''Signatures'''
|{{Func|archive:create-from|$path as xs:string|xs:base64Binary}}<br/>{{Func|archive:create-from|$path as xs:string, $options as map(xs:string, xs:string*)?|xs:base64Binary}}<br/>{{Func|archive:create-from|$path as xs:string, $options as map(xs:string, xs:string*)?, $entries as item()*|xs:base64Binary}}
|-
| '''Summary'''
|This convenience function creates an archive from all files in the specified directory {{Code|$path}}.<br/>The {{Code|$options}} parameter contains archiving options, and the files to be archived can be limited via {{Code|$entries}}. The format of the two last arguments is the same as for identical to [[#archive:create|archive:create]], but two additional options are available:* {{Code|recursive}}: parse all files recursively (default: {{Code|true}}; ignored if entries are specified via the last argument).* {{Code|root-dir}}: use name of supplied directory as archive root directory (default: {{Code|false}}).
|-
| '''Errors'''
|{{Error|file:no-dir|File Module#Errors}} the specified path does not point to a directory.<br/>{{Error|file:is-dir|File Module#Errors}} one of the specified entries points to a directory.<br/>{{Error|file:not-found|File Module#Errors}} a specified entry does not exist.<br/>{{Error|failerror|#Errors}} archive creation failed for some other reason.
|-
| '''Examples'''
|-
| '''Errors'''
|{{Error|failerror|#Errors}} archive creation failed for some other reason.
|-
|'''Examples'''
|-
| width='120' | '''Signatures'''
|{{Func|archive:options|$archive as xs:base64Binary|map(xs:string, xs:string*)}}<br />
|-
| '''Summary'''
|-
| '''Errors'''
|{{Error|format|#Errors}} The packing format is not supported.<br/>{{Error|failerror|#Errors}} archive creation failed for some other reason.
|-
| '''Examples'''
|-
| '''Errors'''
|{{Error|encode|#Errors}} the specified encoding is invalid or not supported, or the string conversion failed. Invalid XML characters will be ignored if the <code>[[Options#CHECKSTRINGS{{Option|CHECKSTRINGS]]</code> option }} is turned off.<br />{{Error|failerror|#Errors}} archive creation failed for some other reason.
|-
| '''Examples'''
|-
| '''Errors'''
|{{Error|failerror|#Errors}} archive creation failed for some other reason.
|-
| '''Examples'''
|-
| '''Errors'''
|{{Error|failerror|#Errors}} archive creation failed for some other reason.
|-
| '''Examples'''
|-
| '''Errors'''
|{{Error|number|#Errors}} the number of entries and contents differs.<br />{{Error|descriptor|#Errors}} entry descriptors contain invalid entry names, timestamps, compression levels or encodings.<br/>{{Error|encode|#Errors}} the specified encoding is invalid or not supported, or the string conversion failed. Invalid XML characters will be ignored if the <code>[[Options#CHECKSTRINGS{{Option|CHECKSTRINGS]]</code> option }} is turned off.<br />{{Error|modify|#Errors}} the entries of the given archive cannot be modified.<br/>{{Error|failerror|#Errors}} archive creation failed for some other reason.
|-
| '''Examples'''
|-
| '''Errors'''
|{{Error|modify|#Errors}} the entries of the given archive cannot be modified.<br/>{{Error|failerror|#Errors}} archive creation failed for some other reason.
|-
| '''Examples'''
=Errors=
 
{{Mark|Updated with Version 9.0}}:
{| class="wikitable" width="100%"
|-
|{{Code|encode}}
|The specified encoding is invalid or not supported, or the string conversion failed. Invalid XML characters will be ignored if the <code>[[Options#CHECKSTRINGS{{Option|CHECKSTRINGS]]</code> option }} is turned off.
|-
|{{Code|failerror}}
|Archive processing failed for some other reason.
|-
;Version 9.0
* Updated: [[#archive:create-from|archive:create-from]]: options added ;Version 9.0 * Updated: error codes updatesupdated; errors now use the module namespace
;Version 8.5
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu