Changes

Jump to navigation Jump to search
16 bytes added ,  18:46, 22 June 2015
no edit summary
$files ! file:read-binary($path || .))
return file:write-binary('mp3.zip', $zip)</pre>
|}
 
==archive:create-from==
 
{{Mark|Introduced with Version 8.3}}:
 
{| width='100%'
|-
| width='120' | '''Signatures'''
|{{Func|archive:create-from|$path as xs:string|xs:base64Binary}}<br/>{{Func|archive:create-from|$path as xs:string, $options as item()|xs:base64Binary}}<br/>{{Func|archive:create-from|$path as xs:string, $options as item(), $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 [[#archive:create|archive:create]].
|-
| '''Errors'''
|{{Error|no-dir|File Module#Errors}} the specified path does not point to a directory.<br/>{{Error|is-dir|File Module#Errors}} one of the specified entries points to a directory.<br/>{{Error|not-found|File Module#Errors}} a specified entry does not exist.<br/>{{Error|ARCH9999|#Errors}} archive creation failed for some other reason.
|-
| '''Examples'''
|This example writes the files of a user’s home directory to <code>archive.zip</code>:
<pre class="brush:xquery">
let $zip := archive:create-from('/home/user/')
return file:write-binary('archive.zip', $zip)
</pre>
|}
file:write-binary($entry, $contents[$p])
)
</pre>
|}
 
==archive:extract-to==
 
{{Mark|Introduced with Version 8.3}}: replaces <code>archive:write</code>
 
{| width='100%'
|-
| width='120' | '''Signatures'''
|{{Func|archive:extract-to|$path as xs:string, $archive as xs:base64Binary|empty-sequence()}}<br/>{{Func|archive:extract-to|$path as xs:string, $archive as xs:base64Binary, $entries as item()*|empty-sequence()}}
|-
| '''Summary'''
|This convenience function writes files of an {{Code|$archive}} directly to the specified directory {{Code|$path}}.<br/>The archive entries to be written can be restricted via {{Code|$entries}}. The format of the argument is the same as for [[#archive:create|archive:create]] (attributes will be ignored).
|-
| '''Errors'''
|{{Error|ARCH9999|#Errors}} archive creation failed for some other reason.
|-
| '''Examples'''
|The following expression unzips all files of an archive to the current directory:
<pre class="brush:xquery">
archive:extract-to('.', file:read-binary('archive.zip'))
</pre>
|}
let $entries := archive:entries($zip)[matches(., '\.x?html?$', 'i')]
return file:write-binary('new.zip', archive:delete($zip, $entries))
</pre>
|}
 
==archive:create-from==
 
{{Mark|Introduced with Version 8.3}}:
 
{| width='100%'
|-
| width='120' | '''Signatures'''
|{{Func|archive:create-from|$path as xs:string|xs:base64Binary}}<br/>{{Func|archive:create-from|$path as xs:string, $options as item()|xs:base64Binary}}<br/>{{Func|archive:create-from|$path as xs:string, $options as item(), $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 [[#archive:create|archive:create]].
|-
| '''Errors'''
|{{Error|no-dir|File Module#Errors}} the specified path does not point to a directory.<br/>{{Error|is-dir|File Module#Errors}} one of the specified entries points to a directory.<br/>{{Error|not-found|File Module#Errors}} a specified entry does not exist.<br/>{{Error|ARCH9999|#Errors}} archive creation failed for some other reason.
|-
| '''Examples'''
|This example writes the files of a user’s home directory to <code>archive.zip</code>:
<pre class="brush:xquery">
let $zip := archive:archive-from('/home/user/')
return file:write-binary('archive.zip', $zip)
</pre>
|}
 
==archive:extract-to==
 
{{Mark|Introduced with Version 8.3}}: replaces <code>archive:write</code>
 
{| width='100%'
|-
| width='120' | '''Signatures'''
|{{Func|archive:extract-to|$path as xs:string, $archive as xs:base64Binary|empty-sequence()}}<br/>{{Func|archive:extract-to|$path as xs:string, $archive as xs:base64Binary, $entries as item()*|empty-sequence()}}
|-
| '''Summary'''
|This convenience function writes files of an {{Code|$archive}} directly to the specified directory {{Code|$path}}.<br/>The archive entries to be written can be restricted via {{Code|$entries}}. The format of the argument is the same as for [[#archive:create|archive:create]] (attributes will be ignored).
|-
| '''Errors'''
|{{Error|ARCH9999|#Errors}} archive creation failed for some other reason.
|-
| '''Examples'''
|This example unzips all files of an archive to the current directory:
<pre class="brush:xquery">
archive:write('.', file:read-binary('archive.zip'))
</pre>
|}
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu