Merge lp:~zorba-coders/zorba/bug-1188033 into lp:zorba/archive-module
- bug-1188033
- Merge into archive-module
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 52 | ||||
Proposed branch: | lp:~zorba-coders/zorba/bug-1188033 | ||||
Merge into: | lp:zorba/archive-module | ||||
Diff against target: |
1647 lines (+375/-434) 47 files modified
src/CMakeLists.txt (+1/-4) src/archive.xsd (+0/-105) src/archive_module.xq (+103/-87) src/archive_module.xq.src/archive_module.cpp (+168/-153) src/archive_module.xq.src/archive_module.h (+24/-4) test/ExpQueryResults/entries_01.xml.res (+1/-2) test/ExpQueryResults/entries_02.xml.res (+1/-2) test/ExpQueryResults/entries_03.xml.res (+1/-1) test/ExpQueryResults/options_01.xml.res (+1/-2) test/ExpQueryResults/options_02.xml.res (+1/-2) test/Queries/create_01.xq (+4/-3) test/Queries/create_02.xq (+2/-2) test/Queries/create_03.spec (+1/-1) test/Queries/create_03.xq (+3/-2) test/Queries/delete_01.xq (+1/-1) test/Queries/delete_02.xq (+1/-2) test/Queries/delete_03.xq (+5/-5) test/Queries/delete_04.xq (+5/-5) test/Queries/dir_01.xq (+3/-3) test/Queries/dir_02.xq (+3/-3) test/Queries/dir_03.xq (+3/-3) test/Queries/dir_04.xq (+4/-4) test/Queries/entries_01.xq (+4/-3) test/Queries/entries_02.xq (+2/-3) test/Queries/entries_03.spec (+1/-1) test/Queries/entries_03.xq (+4/-3) test/Queries/entries_04.spec (+1/-1) test/Queries/entries_04.xq (+4/-3) test/Queries/extract_01.xq (+1/-2) test/Queries/extract_02.xq (+1/-1) test/Queries/extract_03.spec (+1/-1) test/Queries/extract_03.xq (+1/-1) test/Queries/extract_04.xq (+1/-1) test/Queries/extract_05.xq (+4/-4) test/Queries/extract_06.xq (+1/-1) test/Queries/extract_07.xq (+2/-2) test/Queries/options_01.xq (+1/-1) test/Queries/options_02.spec (+1/-1) test/Queries/options_02.xq (+1/-1) test/Queries/options_03.spec (+1/-1) test/Queries/options_03.xq (+1/-1) test/Queries/update_01.xq (+1/-1) test/Queries/update_02.xq (+1/-1) test/Queries/update_03.spec (+1/-1) test/Queries/update_03.xq (+1/-1) test/Queries/update_04.spec (+1/-1) test/Queries/update_04.xq (+1/-1) |
||||
To merge this branch: | bzr merge lp:~zorba-coders/zorba/bug-1188033 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Luis Rodriguez Gonzalez | Approve | ||
Chris Hillery | Approve | ||
Review via email: mp+176523@code.launchpad.net |
Commit message
JSONiqfication for Archive Module Done.
Description of the change
- 52. By Luis Rodriguez Gonzalez
-
Merge with trunk and resolved conflicts
Chris Hillery (ceejatec) wrote : | # |
Also, you have at least one </p> typo in archive.xq.
Always remember to run
ctest -R moduleDocumentation
before committing, to be sure that your XQDoc is syntactically correct and that you didn't forget to document any parameters, etc.
- 53. By Luis Rodriguez Gonzalez
-
All comments fixed
- 54. By Luis Rodriguez Gonzalez
-
Removed commented code
Luis Rodriguez Gonzalez (kuraru) wrote : | # |
> In archive_module.cpp:
>
> 1. Please don't leave commented-out code. Just delete it; it's in the version
> history if we ever need to refer back to it. For example, remove these lines:
>
> + //Item lNameItem = theFactory-
> + //lMemberName = theFactory-
>
>
> 2. As discussed, if possible, create single zorba::Items for all the JSON
> object key strings, eg. "name", "size", etc. Possibly create those in the
> ArchiveModule constructor. Use those constants when creating JSON objects in
> EntriesIterator
> ArchiveEntry:
>
>
> Also don't forget to assign a bug to yourself to create a JSON schema for this
> module, and to go back and update the module and test cases accordingly.
Done.
Luis Rodriguez Gonzalez (kuraru) wrote : | # |
> Also, you have at least one </p> typo in archive.xq.
>
> Always remember to run
>
> ctest -R moduleDocumentation
>
> before committing, to be sure that your XQDoc is syntactically correct and
> that you didn't forget to document any parameters, etc.
Done.
Chris Hillery (ceejatec) wrote : | # |
You didn't actually create singleton zorba::Items for the JSON object key strings. Using C++ #defines isn't the same. This code will still create a separate zorba::Item for the string "name" for every single entry in every archive passed to a:entries().
Luis Rodriguez Gonzalez (kuraru) wrote : | # |
> You didn't actually create singleton zorba::Items for the JSON object key
> strings. Using C++ #defines isn't the same. This code will still create a
> separate zorba::Item for the string "name" for every single entry in every
> archive passed to a:entries().
I used #defines only for the strings that are into the Item, I tried to create static Items into ArchiveModule but at the end I got some linker errors at execution time, I did some research but couldn't fix it so I moved the Items to be created in EntriesIterator and OptionsIterator that in theory created only once insstead of creating one for each entry and options. I will upload a version with the Items created in ArchiveModule and if you have a chance pleaase take a look and let me know if you know how to fix it.
- 55. By Luis Rodriguez Gonzalez
-
Testing global Items for Entries
- 56. By Chris Hillery
-
Definition of globalFormatName.
- 57. By Luis Rodriguez Gonzalez
-
Changes to have global Items from ArchiveModule class made
Chris Hillery (ceejatec) wrote : | # |
Global Items code looks good now!
As a general rule, don't put actual function definitions into header files. Certain small methods (accessors, usually) can be inline for efficiency, but anything more significant can cause code bloat and other problems. I moved the ArchiveModule() constructor definition into archive_module.cpp. With that done, everything looks fine.
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for the following merge proposals:
https:/
Progress dashboard at http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
Voting criteria failed for the following merge proposals:
https:/
Votes: {'Approve': 1, 'Pending': 1, 'Needs commit message': 1}
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue result for https:/
Stage "CommitZorba" failed.
Check console output at http://
Luis Rodriguez Gonzalez (kuraru) : | # |
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for the following merge proposals:
https:/
Progress dashboard at http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
Voting criteria failed for the following merge proposals:
https:/
Votes: {'Approve': 2, 'Needs commit message': 1}
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue result for https:/
Stage "CommitZorba" failed.
Check console output at http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for the following merge proposals:
https:/
Progress dashboard at http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue succeeded - proposal merged!
Preview Diff
1 | === modified file 'src/CMakeLists.txt' | |||
2 | --- src/CMakeLists.txt 2012-07-27 03:43:13 +0000 | |||
3 | +++ src/CMakeLists.txt 2013-07-29 19:28:26 +0000 | |||
4 | @@ -17,11 +17,8 @@ | |||
5 | 17 | INCLUDE_DIRECTORIES("${CMAKE_CURRENT_BINARY_DIR}/archive_module.xq.src") | 17 | INCLUDE_DIRECTORIES("${CMAKE_CURRENT_BINARY_DIR}/archive_module.xq.src") |
6 | 18 | 18 | ||
7 | 19 | DECLARE_ZORBA_MODULE ( | 19 | DECLARE_ZORBA_MODULE ( |
9 | 20 | URI "http://www.zorba-xquery.com/modules/archive" | 20 | URI "http://zorba.io/modules/archive" |
10 | 21 | VERSION 1.0 | 21 | VERSION 1.0 |
11 | 22 | FILE "archive_module.xq" | 22 | FILE "archive_module.xq" |
12 | 23 | LINK_LIBRARIES "${LIBARCHIVE_LIBRARIES}") | 23 | LINK_LIBRARIES "${LIBARCHIVE_LIBRARIES}") |
13 | 24 | 24 | ||
14 | 25 | DECLARE_ZORBA_SCHEMA ( | ||
15 | 26 | URI "http://www.zorba-xquery.com/modules/archive" | ||
16 | 27 | FILE "archive.xsd") | ||
17 | 28 | 25 | ||
18 | === removed file 'src/archive.xsd' | |||
19 | --- src/archive.xsd 2012-09-06 20:40:47 +0000 | |||
20 | +++ src/archive.xsd 1970-01-01 00:00:00 +0000 | |||
21 | @@ -1,105 +0,0 @@ | |||
22 | 1 | <?xml version="1.0"?> | ||
23 | 2 | |||
24 | 3 | <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" | ||
25 | 4 | targetNamespace="http://www.zorba-xquery.com/modules/archive" | ||
26 | 5 | xmlns="http://www.zorba-xquery.com/modules/archive" | ||
27 | 6 | elementFormDefault="qualified" | ||
28 | 7 | attributeFormDefault="unqualified"> | ||
29 | 8 | |||
30 | 9 | <xs:simpleType name="compression-type"> | ||
31 | 10 | <xs:restriction base="xs:string"> | ||
32 | 11 | <xs:enumeration value="store"/> | ||
33 | 12 | <xs:enumeration value="deflate"/> | ||
34 | 13 | <xs:enumeration value="bzip2"/> | ||
35 | 14 | <xs:enumeration value="lzma"/> | ||
36 | 15 | <xs:enumeration value="STORE"/> | ||
37 | 16 | <xs:enumeration value="DEFLATE"/> | ||
38 | 17 | <xs:enumeration value="BZIP2"/> | ||
39 | 18 | <xs:enumeration value="LZMA"/> | ||
40 | 19 | </xs:restriction> | ||
41 | 20 | </xs:simpleType> | ||
42 | 21 | |||
43 | 22 | <xs:simpleType name="format-type"> | ||
44 | 23 | <xs:restriction base="xs:string"> | ||
45 | 24 | <xs:enumeration value="zip"/> | ||
46 | 25 | <xs:enumeration value="tar"/> | ||
47 | 26 | <xs:enumeration value="pax"/> | ||
48 | 27 | <xs:enumeration value="ZIP"/> | ||
49 | 28 | <xs:enumeration value="TAR"/> | ||
50 | 29 | <xs:enumeration value="PAX"/> | ||
51 | 30 | </xs:restriction> | ||
52 | 31 | </xs:simpleType> | ||
53 | 32 | |||
54 | 33 | <xs:simpleType name="boolean-type"> | ||
55 | 34 | <xs:restriction base="xs:string"> | ||
56 | 35 | <xs:enumeration value="true"/> | ||
57 | 36 | <xs:enumeration value="false"/> | ||
58 | 37 | </xs:restriction> | ||
59 | 38 | </xs:simpleType> | ||
60 | 39 | |||
61 | 40 | <xs:simpleType name="entry-name-type"> | ||
62 | 41 | <xs:restriction base="xs:string"/> | ||
63 | 42 | </xs:simpleType> | ||
64 | 43 | |||
65 | 44 | <xs:simpleType name="entry-datetime-type"> | ||
66 | 45 | <xs:restriction base="xs:dateTime"/> | ||
67 | 46 | </xs:simpleType> | ||
68 | 47 | |||
69 | 48 | <xs:simpleType name="entry-size-type"> | ||
70 | 49 | <xs:restriction base="xs:short"/> | ||
71 | 50 | </xs:simpleType> | ||
72 | 51 | |||
73 | 52 | <xs:simpleType name="entry-encoding-type"> | ||
74 | 53 | <xs:restriction base="xs:string"/> | ||
75 | 54 | </xs:simpleType> | ||
76 | 55 | |||
77 | 56 | <xs:simpleType name="entry-type"> | ||
78 | 57 | <xs:restriction base="xs:string"> | ||
79 | 58 | <xs:enumeration value="regular"/> | ||
80 | 59 | <xs:enumeration value="directory"/> | ||
81 | 60 | </xs:restriction> | ||
82 | 61 | </xs:simpleType> | ||
83 | 62 | |||
84 | 63 | <!-- elements --> | ||
85 | 64 | <xs:element name="archive-option-element" | ||
86 | 65 | abstract="true" type="xs:string"/> | ||
87 | 66 | |||
88 | 67 | <xs:element name="compression" | ||
89 | 68 | type="compression-type" | ||
90 | 69 | substitutionGroup="archive-option-element"/> | ||
91 | 70 | |||
92 | 71 | <xs:element name="format" type="format-type" | ||
93 | 72 | substitutionGroup="archive-option-element"/> | ||
94 | 73 | |||
95 | 74 | <xs:element name="skip-extra-attributes" type="boolean-type" | ||
96 | 75 | substitutionGroup="archive-option-element"/> | ||
97 | 76 | |||
98 | 77 | <xs:element name="options"> | ||
99 | 78 | <xs:complexType> | ||
100 | 79 | <xs:sequence> | ||
101 | 80 | <xs:element ref="archive-option-element" | ||
102 | 81 | minOccurs="0" maxOccurs="unbounded"/> | ||
103 | 82 | </xs:sequence> | ||
104 | 83 | </xs:complexType> | ||
105 | 84 | </xs:element> | ||
106 | 85 | |||
107 | 86 | <xs:element name="entry"> | ||
108 | 87 | <xs:complexType> | ||
109 | 88 | <xs:simpleContent> | ||
110 | 89 | <xs:extension base="entry-name-type"> | ||
111 | 90 | <xs:attributeGroup ref="entry-attributes"/> | ||
112 | 91 | </xs:extension> | ||
113 | 92 | </xs:simpleContent> | ||
114 | 93 | </xs:complexType> | ||
115 | 94 | </xs:element> | ||
116 | 95 | |||
117 | 96 | <!-- entry attributes --> | ||
118 | 97 | <xs:attributeGroup name="entry-attributes"> | ||
119 | 98 | <xs:attribute name="type" type="entry-type"/> | ||
120 | 99 | <xs:attribute name="size" type="entry-size-type"/> | ||
121 | 100 | <xs:attribute name="last-modified" type="entry-datetime-type"/> | ||
122 | 101 | <xs:attribute name="encoding" type="entry-encoding-type"/> | ||
123 | 102 | <xs:attribute name="compression" type="compression-type"/> | ||
124 | 103 | </xs:attributeGroup> | ||
125 | 104 | |||
126 | 105 | </xs:schema> | ||
127 | 106 | 0 | ||
128 | === modified file 'src/archive_module.xq' | |||
129 | --- src/archive_module.xq 2012-12-21 22:10:19 +0000 | |||
130 | +++ src/archive_module.xq 2013-07-29 19:28:26 +0000 | |||
131 | @@ -1,4 +1,4 @@ | |||
133 | 1 | xquery version "1.0"; | 1 | jsoniq version "1.0"; |
134 | 2 | 2 | ||
135 | 3 | (: | 3 | (: |
136 | 4 | : Copyright 2012 The FLWOR Foundation. | 4 | : Copyright 2012 The FLWOR Foundation. |
137 | @@ -17,62 +17,62 @@ | |||
138 | 17 | :) | 17 | :) |
139 | 18 | 18 | ||
140 | 19 | (:~ | 19 | (:~ |
142 | 20 | : <p>This module provides functionality to work with (possibly compressed) | 20 | : This module provides functionality to work with (possibly compressed) |
143 | 21 | : archives. For example, it provides functions to retrieve the names or | 21 | : archives. For example, it provides functions to retrieve the names or |
144 | 22 | : extract the values of several entries in a ZIP archive. Moreover, | 22 | : extract the values of several entries in a ZIP archive. Moreover, |
146 | 23 | : there exist functions that allow to create or update archives.</p> | 23 | : there exist functions that allow to create or update archives.<p/> |
147 | 24 | : | 24 | : |
149 | 25 | : <p>The following archive formats and compression algorithms are supported: | 25 | : The following archive formats and compression algorithms are supported: |
150 | 26 | : <ul> | 26 | : <ul> |
151 | 27 | : <li>ZIP (with compression DEFLATE or STORE)</li> | 27 | : <li>ZIP (with compression DEFLATE or STORE)</li> |
152 | 28 | : <li>TAR (with compression GZIP)</li> | 28 | : <li>TAR (with compression GZIP)</li> |
153 | 29 | : </ul> | 29 | : </ul> |
155 | 30 | : </p> | 30 | : <p/> |
156 | 31 | : | 31 | : |
157 | 32 | : @author Luis Rodgriguez, Juan Zacarias, and Matthias Brantner | 32 | : @author Luis Rodgriguez, Juan Zacarias, and Matthias Brantner |
158 | 33 | : | 33 | : |
159 | 34 | : @library <a href="http://code.google.com/p/libarchive/">libarchive</a> | 34 | : @library <a href="http://code.google.com/p/libarchive/">libarchive</a> |
160 | 35 | : @project Zorba/Archive | 35 | : @project Zorba/Archive |
161 | 36 | :) | 36 | :) |
163 | 37 | module namespace a = "http://www.zorba-xquery.com/modules/archive"; | 37 | module namespace a = "http://zorba.io/modules/archive"; |
164 | 38 | 38 | ||
165 | 39 | import schema namespace options = "http://www.zorba-xquery.com/modules/archive"; | ||
166 | 40 | |||
167 | 41 | declare namespace ver = "http://www.zorba-xquery.com/options/versioning"; | 39 | declare namespace ver = "http://www.zorba-xquery.com/options/versioning"; |
168 | 42 | declare option ver:module-version "1.0"; | 40 | declare option ver:module-version "1.0"; |
169 | 43 | 41 | ||
170 | 44 | (:~ | 42 | (:~ |
172 | 45 | : Creates a new ZIP archive out of the given entries and contents. | 43 | : Creates a new ZIP archive out of the given entries and contents. <p/> |
173 | 46 | : | 44 | : |
175 | 47 | : <p>All entries are compressed with the DEFLATE compression algorithm.</p> | 45 | : All entries are compressed with the DEFLATE compression algorithm.<p/> |
176 | 48 | : | 46 | : |
179 | 49 | : <p>The parameters $entries and $contents have the same meaning as for | 47 | : The parameters $entries and $contents have the same meaning as for |
180 | 50 | : the function a:create with three arguments.</p> | 48 | : the function a:create with three arguments.<p/> |
181 | 51 | : | 49 | : |
183 | 52 | : <p>Entry entries can include a type attribute, this attribute can have one | 50 | : Entry entries can include a type element, this element can have one |
184 | 53 | : of two possible values: "regular" or "directory". If "regular" is | 51 | : of two possible values: "regular" or "directory". If "regular" is |
185 | 54 | : specified then the entry will be created as a regular file; if "directory" | 52 | : specified then the entry will be created as a regular file; if "directory" |
186 | 55 | : is specified then the entry will be created as a directory, no contents | 53 | : is specified then the entry will be created as a directory, no contents |
187 | 56 | : will be read from $contents in this case. If no value is specified for type | 54 | : will be read from $contents in this case. If no value is specified for type |
189 | 57 | : then it will be set to "regular". Example: | 55 | : then it will be set to "regular". <p/> |
190 | 56 | : Example: | ||
191 | 58 | : <pre> | 57 | : <pre> |
192 | 59 | : $zip-file := a:create( | 58 | : $zip-file := a:create( |
194 | 60 | : (<a:entry encoding="ISO-8859-1" type="directory">dir1</a:entry>, "dir1/file1"), | 59 | : ({ "encoding" : "ISO-8859-1", "type" : "directory", "name" : "dir1" }, "dir1/file1"), |
195 | 61 | : ("file contents")) | 60 | : ("file contents")) |
196 | 62 | : </pre> | 61 | : </pre> |
198 | 63 | : </p> | 62 | : <p/> |
199 | 64 | : | 63 | : |
200 | 65 | : @param $entries the meta data for the entries in the archive. Each entry | 64 | : @param $entries the meta data for the entries in the archive. Each entry |
202 | 66 | : can be of type xs:string or an element with name a:entry. | 65 | : can be of type xs:string or a JSON oibject describing the entry. |
203 | 67 | : @param $contents the content for the archive. Each item in the sequence | 66 | : @param $contents the content for the archive. Each item in the sequence |
204 | 68 | : can be of type xs:string or xs:base64Binary. | 67 | : can be of type xs:string or xs:base64Binary. |
205 | 69 | : | 68 | : |
206 | 70 | : @return the generated archive as xs:base64Binary | 69 | : @return the generated archive as xs:base64Binary |
207 | 71 | : | 70 | : |
212 | 72 | : @error a:ARCH0001 if the number of entry elements differs from the number | 71 | : @error a:ENTRY-COUNT-MISMATCH if the number of entries that don't describe directories |
213 | 73 | : of items in the $contents sequence: count($entries) ne count($contents) | 72 | : differs from the number of items in the $contents sequence: |
214 | 74 | : @error a:ARCH0003 if a value for an entry element is invalid | 73 | : count($non-directory-entries) ne count($contents) |
215 | 75 | : @error a:ARCH0004 if a given encoding is invalid or not supported | 74 | : @error a:INVALID-ENTRY-VALS if a values in an entry object are invalid |
216 | 75 | : @error a:INVALID-ENCODING if a given encoding is invalid or not supported | ||
217 | 76 | : @error err:FORG0006 if an item in the contents sequence is not of type xs:string | 76 | : @error err:FORG0006 if an item in the contents sequence is not of type xs:string |
218 | 77 | : or xs:base64Binary | 77 | : or xs:base64Binary |
219 | 78 | :) | 78 | :) |
220 | @@ -82,94 +82,106 @@ | |||
221 | 82 | as xs:base64Binary external; | 82 | as xs:base64Binary external; |
222 | 83 | 83 | ||
223 | 84 | (:~ | 84 | (:~ |
225 | 85 | : Creates a new archive out of the given entries and contents. | 85 | : Creates a new archive out of the given entries and contents. <p/> |
226 | 86 | : | 86 | : |
228 | 87 | : <p>The $entries arguments provides meta data for each entry in the archive. | 87 | : The $entries arguments provides meta data for each entry in the archive. |
229 | 88 | : For example, the name of the entry (mandatory) or the last-modified date | 88 | : For example, the name of the entry (mandatory) or the last-modified date |
230 | 89 | : (optional). An entry can either be of type xs:string to describe the entry | 89 | : (optional). An entry can either be of type xs:string to describe the entry |
232 | 90 | : name or of type xs:base64Binary to provide additional meta data.</p> | 90 | : name or of type xs:base64Binary to provide additional meta data.<p/> |
233 | 91 | : | 91 | : |
235 | 92 | : <p>The $contents sequence provides the data (xs:string or xs:base64Binary) for | 92 | : The $contents sequence provides the data (xs:string or xs:base64Binary) for |
236 | 93 | : the entries that should be included in the archive. Its length needs to | 93 | : the entries that should be included in the archive. Its length needs to |
239 | 94 | : match the length of the $entries sequence (a:ARCH0001). All items of type | 94 | : match the length of the entries in the $entries sequence that don't describe |
240 | 95 | : xs:base64Binary are decoded before being added to the archive.</p> | 95 | : directory entries (a:ARCH0001). All items of type xs:base64Binary are decoded |
241 | 96 | : before being added to the archive.<p/> | ||
242 | 96 | : | 97 | : |
244 | 97 | : <p>For each entry, the name, last-modified date and time, and compression | 98 | : For each entry, the name, last-modified date and time, and compression |
245 | 98 | : can be specified. In addition, an encoding can be specified which is used to | 99 | : can be specified. In addition, an encoding can be specified which is used to |
246 | 99 | : store entries of type xs:string. If no last-modified attribute is given, the | 100 | : store entries of type xs:string. If no last-modified attribute is given, the |
247 | 100 | : default is the current date and time. The compression is useful if various | 101 | : default is the current date and time. The compression is useful if various |
248 | 101 | : entries in a ZIP archive are compressed using different compression | 102 | : entries in a ZIP archive are compressed using different compression |
250 | 102 | : algorithms (i.e. store or deflate).</p> | 103 | : algorithms (i.e. store or deflate).<p/> |
251 | 103 | : | 104 | : |
256 | 104 | : <p>For example, the following sequence may be used to describe an archive | 105 | : For example, the following sequence may be used to describe an archive |
257 | 105 | : containing three elements: | 106 | : containing two elements: <p/> |
258 | 106 | : <pre class="ace-static" ace-mode="xquery"><![CDATA[<a:entry last-modified="{fn:current-dateTime()}">myfile.txt</a:entry> | 107 | : <pre class="ace-static" ace-mode="xquery">{ |
259 | 107 | : <a:entry encoding="ISO-8859-1" compression="store">dir/myfile.xml</a:entry>]]> | 108 | : "last-modified" : "{fn:current-dateTime()}" |
260 | 109 | : "name" : "myfile.txt" | ||
261 | 110 | : }, | ||
262 | 111 | : { | ||
263 | 112 | : "encoding" : "ISO-8859-1", | ||
264 | 113 | : "compression" : "store", | ||
265 | 114 | : "name" : "dir/myfile.xml" | ||
266 | 115 | : } | ||
267 | 108 | : </pre> | 116 | : </pre> |
269 | 109 | : </p> | 117 | : <p/> |
270 | 110 | : | 118 | : |
273 | 111 | : <p>The $options argument may be used to describe general options for the | 119 | : The $options argument may be used to describe general options for the |
274 | 112 | : archive. For example, the following option element can be used to create a ZIP | 120 | : archive. For example, the following options can be used to create a ZIP |
275 | 113 | : archive in which all entries are compressed with the DEFLATE compression | 121 | : archive in which all entries are compressed with the DEFLATE compression |
281 | 114 | : algorithm: | 122 | : algorithm: <p/> |
282 | 115 | : <pre class="ace-static" ace-mode="xquery"><![CDATA[<archive:options> | 123 | : <pre class="ace-static" ace-mode="xquery">{ |
283 | 116 | : <archive:format>ZIP</archive:format> | 124 | : "format" : "ZIP", |
284 | 117 | : <archive:compression>DEFLATE</archive:compression> | 125 | : "compression" : "DEFLATE" |
285 | 118 | : </archive:options>]]> | 126 | : } |
286 | 119 | : </pre> | 127 | : </pre> |
288 | 120 | : </p> | 128 | : <p/> |
289 | 121 | : | 129 | : |
292 | 122 | : <p>The result of the function is the generated archive as a item of type | 130 | : The result of the function is the generated archive as a item of type |
293 | 123 | : xs:base64Binary.</p> | 131 | : xs:base64Binary.<p/> |
294 | 124 | : | 132 | : |
295 | 125 | : | 133 | : |
296 | 126 | : @param $entries the meta data for the entries in the archive. Each entry | 134 | : @param $entries the meta data for the entries in the archive. Each entry |
298 | 127 | : can be of type xs:string or an element with name a:entry. | 135 | : can be of type xs:string or an JSON object describing the entry. |
299 | 128 | : @param $contents the content for the archive. Each item in the sequence | 136 | : @param $contents the content for the archive. Each item in the sequence |
300 | 129 | : can be of type xs:string or xs:base64Binary. | 137 | : can be of type xs:string or xs:base64Binary. |
301 | 130 | : @param $options the options used to generate the archive. | 138 | : @param $options the options used to generate the archive. |
302 | 131 | : | 139 | : |
303 | 132 | : @return the generated archive as xs:base64Binary | 140 | : @return the generated archive as xs:base64Binary |
304 | 133 | : | 141 | : |
310 | 134 | : @error a:ARCH0001 if the number of entry elements differs from the number | 142 | : @error a:ENTRY-COUNT-MISMATCH if the number of entries describing non-directories differs |
311 | 135 | : of items in the $contents sequence: count($entries) ne count($contents) | 143 | : from the number of items in the $contents sequence: |
312 | 136 | : @error a:ARCH0002 if the options argument contains invalid values | 144 | : count($non-directoy-entries) ne count($contents) |
313 | 137 | : @error a:ARCH0003 if a value for an entry element is invalid | 145 | : @error a:INVALID-OPTIONS if the options argument contains invalid values |
314 | 138 | : @error a:ARCH0004 if a given encoding is invalid or not supported | 146 | : @error a:INVALID-ENTRY-VALS if any values in an entry are invalid |
315 | 147 | : @error a:INVALID-ENCODING if a given encoding is invalid or not supported | ||
316 | 148 | : @error a:DIFFERENT-COMPRESSIONS-NOT-SUPPORTED if different compression algorithms | ||
317 | 149 | : were selected but the actual version of libarchive doesn't support it. | ||
318 | 139 | : @error err:FORG0006 if an item in the contents sequence is not of type xs:string | 150 | : @error err:FORG0006 if an item in the contents sequence is not of type xs:string |
319 | 140 | : or xs:base64Binary | 151 | : or xs:base64Binary |
320 | 141 | :) | 152 | :) |
321 | 142 | declare function a:create( | 153 | declare function a:create( |
322 | 143 | $entries as item()*, | 154 | $entries as item()*, |
323 | 144 | $contents as item()*, | 155 | $contents as item()*, |
325 | 145 | $options as element(a:options)) | 156 | $options as object()) |
326 | 146 | as xs:base64Binary external; | 157 | as xs:base64Binary external; |
327 | 147 | 158 | ||
328 | 148 | (:~ | 159 | (:~ |
330 | 149 | : Returns the header information of all entries in the given archive. | 160 | : Returns the header information of all entries in the given archive as a JSON |
331 | 161 | : objects sequence. <p/> | ||
332 | 150 | : | 162 | : |
334 | 151 | : <p>Such information includes the name of the entry, the uncompressed size, | 163 | : Such information includes the name of the entry, the uncompressed size, |
335 | 152 | : as well as the last-modified timestamp. Note that not all values are | 164 | : as well as the last-modified timestamp. Note that not all values are |
337 | 153 | : available in every archive.</p> | 165 | : available in every archive.<p/> |
338 | 154 | : | 166 | : |
339 | 155 | : @param $archive the archive to list the entries from as xs:base64Binary | 167 | : @param $archive the archive to list the entries from as xs:base64Binary |
340 | 156 | : | 168 | : |
341 | 157 | : @return a sequence of strings, one for each entry in the archive | 169 | : @return a sequence of strings, one for each entry in the archive |
342 | 158 | : | 170 | : |
344 | 159 | : @error a:ARCH9999 if $archive is not an archive or corrupted | 171 | : @error a:CORRUPTED-ARCHIVE if $archive is not an archive or corrupted |
345 | 160 | :) | 172 | :) |
346 | 161 | declare function a:entries($archive as xs:base64Binary) | 173 | declare function a:entries($archive as xs:base64Binary) |
348 | 162 | as element(a:entry)* external; | 174 | as object()* external; |
349 | 163 | 175 | ||
350 | 164 | (:~ | 176 | (:~ |
351 | 165 | : Extracts the contents of all entries in the given archive as text | 177 | : Extracts the contents of all entries in the given archive as text |
353 | 166 | : using UTF-8 as default encoding. | 178 | : using UTF-8 as default encoding. <p/> |
354 | 167 | : | 179 | : |
355 | 168 | : @param $archive the archive to extract the entries from as xs:base64Binary | 180 | : @param $archive the archive to extract the entries from as xs:base64Binary |
356 | 169 | : | 181 | : |
357 | 170 | : @return one string for the contents of each entry in the archive | 182 | : @return one string for the contents of each entry in the archive |
358 | 171 | : | 183 | : |
360 | 172 | : @error a:ARCH9999 if $archive is not an archive or corrupted | 184 | : @error a:CORRUPTED-ARCHIVE if $archive is not an archive or corrupted |
361 | 173 | : @error err:FOCH0001 if any of the entries contains invalid utf-8 characters | 185 | : @error err:FOCH0001 if any of the entries contains invalid utf-8 characters |
362 | 174 | :) | 186 | :) |
363 | 175 | declare function a:extract-text($archive as xs:base64Binary) | 187 | declare function a:extract-text($archive as xs:base64Binary) |
364 | @@ -178,7 +190,7 @@ | |||
365 | 178 | (:~ | 190 | (:~ |
366 | 179 | : Extracts the contets of the entries identified by a given sequence of | 191 | : Extracts the contets of the entries identified by a given sequence of |
367 | 180 | : names as text. | 192 | : names as text. |
369 | 181 | : The default encoding used to read the string is UTF-8. | 193 | : The default encoding used to read the string is UTF-8. <p/> |
370 | 182 | : | 194 | : |
371 | 183 | : @param $archive the archive to extract the entries from as xs:base64Binary | 195 | : @param $archive the archive to extract the entries from as xs:base64Binary |
372 | 184 | : @param $entry-names a sequence of names for entries which should be extracted | 196 | : @param $entry-names a sequence of names for entries which should be extracted |
373 | @@ -186,7 +198,7 @@ | |||
374 | 186 | : @return a sequence of strings for the given sequence of names or the | 198 | : @return a sequence of strings for the given sequence of names or the |
375 | 187 | : empty sequence if no entries match the given names. | 199 | : empty sequence if no entries match the given names. |
376 | 188 | : | 200 | : |
378 | 189 | : @error a:ARCH9999 if $archive is not an archive or corrupted | 201 | : @error a:CORRUPTED-ARCHIVE if $archive is not an archive or corrupted |
379 | 190 | : @error err:FOCH0001 if any of the entries requested contains invalid utf-8 characters | 202 | : @error err:FOCH0001 if any of the entries requested contains invalid utf-8 characters |
380 | 191 | :) | 203 | :) |
381 | 192 | declare function a:extract-text($archive as xs:base64Binary, $entry-names as xs:string*) | 204 | declare function a:extract-text($archive as xs:base64Binary, $entry-names as xs:string*) |
382 | @@ -194,7 +206,7 @@ | |||
383 | 194 | 206 | ||
384 | 195 | (:~ | 207 | (:~ |
385 | 196 | : Extracts the contets of the entries identified by a given sequence of | 208 | : Extracts the contets of the entries identified by a given sequence of |
387 | 197 | : names as text. Each entry is treated with the given encoding. | 209 | : names as text. Each entry is treated with the given encoding. <p/> |
388 | 198 | : | 210 | : |
389 | 199 | : @param $archive the archive to extract the entries from as xs:base64Binary | 211 | : @param $archive the archive to extract the entries from as xs:base64Binary |
390 | 200 | : @param $entry-names a sequence of entry names that should be extracted | 212 | : @param $entry-names a sequence of entry names that should be extracted |
391 | @@ -203,8 +215,8 @@ | |||
392 | 203 | : @return a sequence of strings for the given sequence of names or the | 215 | : @return a sequence of strings for the given sequence of names or the |
393 | 204 | : empty sequence if no entries match the given names. | 216 | : empty sequence if no entries match the given names. |
394 | 205 | : | 217 | : |
397 | 206 | : @error a:ARCH9999 if $archive is not an archive or corrupted | 218 | : @error a:CORRUPTED-ARCHIVE if $archive is not an archive or corrupted |
398 | 207 | : @error a:ARCH0004 if the given $encoding is invalid or not supported | 219 | : @error a:INVALID-ENCODING if the given $encoding is invalid or not supported |
399 | 208 | : @error err:FOCH0001 if a transcoding error happens | 220 | : @error err:FOCH0001 if a transcoding error happens |
400 | 209 | :) | 221 | :) |
401 | 210 | declare function a:extract-text( | 222 | declare function a:extract-text( |
402 | @@ -215,20 +227,20 @@ | |||
403 | 215 | 227 | ||
404 | 216 | (:~ | 228 | (:~ |
405 | 217 | : Returns the entries identified by the given paths from the archive | 229 | : Returns the entries identified by the given paths from the archive |
407 | 218 | : as base64Binary. | 230 | : as base64Binary. <p/> |
408 | 219 | : | 231 | : |
409 | 220 | : @param $archive the archive to extract the entries from as xs:base64Binary | 232 | : @param $archive the archive to extract the entries from as xs:base64Binary |
410 | 221 | : | 233 | : |
411 | 222 | : @return one xs:base64Binary item for the contents of each entry in the archive | 234 | : @return one xs:base64Binary item for the contents of each entry in the archive |
412 | 223 | : | 235 | : |
414 | 224 | : @error a:ARCH9999 if $archive is not an archive or corrupted | 236 | : @error a:CORRUPTED-ARCHIVE if $archive is not an archive or corrupted |
415 | 225 | :) | 237 | :) |
416 | 226 | declare function a:extract-binary($archive as xs:base64Binary) | 238 | declare function a:extract-binary($archive as xs:base64Binary) |
417 | 227 | as xs:base64Binary* external; | 239 | as xs:base64Binary* external; |
418 | 228 | 240 | ||
419 | 229 | (:~ | 241 | (:~ |
420 | 230 | : Returns the entries identified by the given paths from the archive | 242 | : Returns the entries identified by the given paths from the archive |
422 | 231 | : as base64Binary. | 243 | : as base64Binary. <p/> |
423 | 232 | : | 244 | : |
424 | 233 | : @param $archive the archive to extract the entries from as xs:base64Binary | 245 | : @param $archive the archive to extract the entries from as xs:base64Binary |
425 | 234 | : | 246 | : |
426 | @@ -237,66 +249,70 @@ | |||
427 | 237 | : @return a sequence of xs:base64Binary itmes for the given sequence of names | 249 | : @return a sequence of xs:base64Binary itmes for the given sequence of names |
428 | 238 | : or the empty sequence if no entries match the given names. | 250 | : or the empty sequence if no entries match the given names. |
429 | 239 | : | 251 | : |
431 | 240 | : @error a:ARCH9999 if $archive is not an archive or corrupted | 252 | : @error a:CORRUPTED-ARCHIVE if $archive is not an archive or corrupted |
432 | 241 | :) | 253 | :) |
433 | 242 | declare function a:extract-binary($archive as xs:base64Binary, $entry-names as xs:string*) | 254 | declare function a:extract-binary($archive as xs:base64Binary, $entry-names as xs:string*) |
434 | 243 | as xs:base64Binary* external; | 255 | as xs:base64Binary* external; |
435 | 244 | 256 | ||
436 | 245 | (:~ | 257 | (:~ |
437 | 246 | : Adds and replaces entries in an archive according to | 258 | : Adds and replaces entries in an archive according to |
439 | 247 | : the given spec. The contents can be string and base64Binary items. | 259 | : the given spec. The contents can be string and base64Binary items. <p/> |
440 | 248 | : | 260 | : |
443 | 249 | : <p>The parameters $entries and $contents have the same meaning as for | 261 | : The parameters $entries and $contents have the same meaning as for |
444 | 250 | : the function a:create with three arguments.</p> | 262 | : the function a:create with three arguments.<p/> |
445 | 251 | : | 263 | : |
446 | 252 | : @param $archive the archive to add or replace content | 264 | : @param $archive the archive to add or replace content |
447 | 253 | : @param $entries the meta data for the entries in the archive. Each entry | 265 | : @param $entries the meta data for the entries in the archive. Each entry |
449 | 254 | : can be of type xs:string or an element with name a:entry. | 266 | : can be of type xs:string or a JSON object. For mandatory fields in the |
450 | 267 | : JSON object see create function. | ||
451 | 255 | : @param $contents the content for the archive. Each item in the sequence | 268 | : @param $contents the content for the archive. Each item in the sequence |
452 | 256 | : can be of type xs:string or xs:base64Binary. | 269 | : can be of type xs:string or xs:base64Binary. |
453 | 257 | : | 270 | : |
454 | 258 | : @return the updated xs:base64Binary | 271 | : @return the updated xs:base64Binary |
455 | 259 | : | 272 | : |
460 | 260 | : @error a:ARCH0001 if the number of entry elements differs from the number | 273 | : @error a:ENTRY-COUNT-MISMATCH if the number of entry elements differs from the number |
461 | 261 | : of items in the $contents sequence: count($entries) ne count($contents) | 274 | : of items in the $contents sequence: count($non-directory-entries) ne count($contents) |
462 | 262 | : @error a:ARCH0003 if a value for an entry element is invalid | 275 | : @error a:INVALID-ENTRY-VALS if a value for an entry element is invalid |
463 | 263 | : @error a:ARCH0004 if a given encoding is invalid or not supported | 276 | : @error a:INVALID-ENCODING if a given encoding is invalid or not supported |
464 | 277 | : @error a:DIFFERENT-COMPRESSIONS-NOT-SUPPORTED if different compression algorithms | ||
465 | 278 | : were selected but the actual version of libarchive doesn't support it. | ||
466 | 264 | : @error err:FORG0006 if an item in the contents sequence is not of type xs:string | 279 | : @error err:FORG0006 if an item in the contents sequence is not of type xs:string |
467 | 265 | : or xs:base64Binary | 280 | : or xs:base64Binary |
469 | 266 | : @error a:ARCH9999 if $archive is not an archive or corrupted | 281 | : @error a:CORRUPTED-ARCHIVE if $archive is not an archive or corrupted |
470 | 267 | : | 282 | : |
471 | 268 | :) | 283 | :) |
472 | 269 | declare function a:update($archive as xs:base64Binary, $entries as item()*, $contents as item()*) | 284 | declare function a:update($archive as xs:base64Binary, $entries as item()*, $contents as item()*) |
473 | 270 | as xs:base64Binary external; | 285 | as xs:base64Binary external; |
474 | 271 | 286 | ||
475 | 272 | (:~ | 287 | (:~ |
477 | 273 | : Deletes entries from an archive. | 288 | : Deletes entries from an archive. <p/> |
478 | 274 | : | 289 | : |
479 | 275 | : @param $archive the archive to extract the entries from as xs:base64Binary | 290 | : @param $archive the archive to extract the entries from as xs:base64Binary |
480 | 276 | : @param $entry-names a sequence of names for entries which should be deleted | 291 | : @param $entry-names a sequence of names for entries which should be deleted |
481 | 277 | : | 292 | : |
482 | 278 | : @return the updated base64Binary | 293 | : @return the updated base64Binary |
483 | 279 | : | 294 | : |
485 | 280 | : @error a:ARCH9999 if $archive is not an archive or corrupted | 295 | : @error a:CORRUPTED-ARCHIVE if $archive is not an archive or corrupted |
486 | 281 | :) | 296 | :) |
487 | 282 | declare function a:delete($archive as xs:base64Binary, $entry-names as xs:string*) | 297 | declare function a:delete($archive as xs:base64Binary, $entry-names as xs:string*) |
488 | 283 | as xs:base64Binary external; | 298 | as xs:base64Binary external; |
489 | 284 | 299 | ||
490 | 285 | (:~ | 300 | (:~ |
492 | 286 | : Returns the algorithm and format options of the given archive. | 301 | : Returns the algorithm and format options as a JSON object for a given archive. |
493 | 287 | : For example, for a ZIP archive, the following options element | 302 | : For example, for a ZIP archive, the following options element |
499 | 288 | : would be returned: | 303 | : would be returned: <p/> |
500 | 289 | : <pre class="ace-static" ace-mode="xquery"><![CDATA[<archive:options> | 304 | : <pre class="ace-static" ace-mode="xquery">{ |
501 | 290 | : <archive:format>ZIP</archive:format> | 305 | : "format" : "ZIP", |
502 | 291 | : <archive:compressionDEFLATE</archive:compression> | 306 | : "compression" : "DEFLATE" |
503 | 292 | : </archive:options>]]> | 307 | : } |
504 | 293 | : </pre> | 308 | : </pre> |
505 | 309 | : <p/> | ||
506 | 294 | : | 310 | : |
507 | 295 | : @param $archive the archive as xs:base64Binary | 311 | : @param $archive the archive as xs:base64Binary |
508 | 296 | : | 312 | : |
510 | 297 | : @return the algorithm and format options | 313 | : @return the algorithm and format options as a JSON object |
511 | 298 | : | 314 | : |
513 | 299 | : @error a:ARCH9999 if $archive is not an archive or corrupted | 315 | : @error a:CORRUPTED-ARCHIVE if $archive is not an archive or corrupted |
514 | 300 | :) | 316 | :) |
515 | 301 | declare function a:options($archive as xs:base64Binary) | 317 | declare function a:options($archive as xs:base64Binary) |
517 | 302 | as element(a:options) external; | 318 | as object() external; |
518 | 303 | 319 | ||
519 | === modified file 'src/archive_module.xq.src/archive_module.cpp' | |||
520 | --- src/archive_module.xq.src/archive_module.cpp 2013-06-21 04:18:40 +0000 | |||
521 | +++ src/archive_module.xq.src/archive_module.cpp 2013-07-29 19:28:26 +0000 | |||
522 | @@ -45,8 +45,23 @@ | |||
523 | 45 | #include "archive_module.h" | 45 | #include "archive_module.h" |
524 | 46 | #include "config.h" | 46 | #include "config.h" |
525 | 47 | 47 | ||
526 | 48 | #define ERROR_ENTRY_COUNT_MISMATCH "ENTRY-COUNT" | ||
527 | 49 | #define ERROR_INVALID_OPTIONS "INVALID-OPTIONS" | ||
528 | 50 | #define ERROR_INVALID_ENTRY_VALS "INVALID-ENTRY-VALS" | ||
529 | 51 | #define ERROR_INVALID_ENCODING "INVALID-ENCODING" | ||
530 | 52 | #define ERROR_CORRUPTED_ARCHIVE "CORRUPTED-ARCHIVE" | ||
531 | 53 | #define ERROR_DIFFERENT_COMPRESSIONS_NOT_SUPPORTED "DIFFERENT-COMPRESSIONS-NOT-SUPPORTED" | ||
532 | 54 | |||
533 | 48 | namespace zorba { namespace archive { | 55 | namespace zorba { namespace archive { |
534 | 49 | 56 | ||
535 | 57 | // Allocating global keys | ||
536 | 58 | zorba::Item ArchiveModule::globalFormatKey; | ||
537 | 59 | zorba::Item ArchiveModule::globalCompressionKey; | ||
538 | 60 | zorba::Item ArchiveModule::globalNameKey; | ||
539 | 61 | zorba::Item ArchiveModule::globalTypeKey; | ||
540 | 62 | zorba::Item ArchiveModule::globalSizeKey; | ||
541 | 63 | zorba::Item ArchiveModule::globalLastModifiedKey; | ||
542 | 64 | zorba::Item ArchiveModule::globalEncodingKey; | ||
543 | 50 | 65 | ||
544 | 51 | /******************************************************************************* | 66 | /******************************************************************************* |
545 | 52 | ******************************************************************************/ | 67 | ******************************************************************************/ |
546 | @@ -146,10 +161,26 @@ | |||
547 | 146 | std::ostringstream lMsg; | 161 | std::ostringstream lMsg; |
548 | 147 | lMsg << i.getStringValue() | 162 | lMsg << i.getStringValue() |
549 | 148 | << ": invalid value for last-modified attribute "; | 163 | << ": invalid value for last-modified attribute "; |
551 | 149 | ArchiveFunction::throwError("ARCH0003", lMsg.str().c_str()); | 164 | ArchiveFunction::throwError(ERROR_INVALID_ENTRY_VALS, lMsg.str().c_str()); |
552 | 150 | } | 165 | } |
553 | 151 | } | 166 | } |
554 | 152 | 167 | ||
555 | 168 | zorba::Item& | ||
556 | 169 | ArchiveModule::getGlobalItems(enum ArchiveModule::GLOBAL_ITEMS g) | ||
557 | 170 | { | ||
558 | 171 | switch(g) | ||
559 | 172 | { | ||
560 | 173 | case FORMAT: return globalFormatKey; | ||
561 | 174 | case COMPRESSION: return globalCompressionKey; | ||
562 | 175 | case NAME: return globalNameKey; | ||
563 | 176 | case TYPE: return globalTypeKey; | ||
564 | 177 | case SIZE: return globalSizeKey; | ||
565 | 178 | case LAST_MODIFIED: return globalLastModifiedKey; | ||
566 | 179 | case ENCODING: return globalEncodingKey; | ||
567 | 180 | // we should never touch the default clause but ... | ||
568 | 181 | default: return globalFormatKey; | ||
569 | 182 | } | ||
570 | 183 | } | ||
571 | 153 | 184 | ||
572 | 154 | /******************************************************************************* | 185 | /******************************************************************************* |
573 | 155 | ****************************** ArchiveFunction ******************************** | 186 | ****************************** ArchiveFunction ******************************** |
574 | @@ -209,34 +240,36 @@ | |||
575 | 209 | void | 240 | void |
576 | 210 | ArchiveFunction::ArchiveEntry::setValues(zorba::Item& aEntry) | 241 | ArchiveFunction::ArchiveEntry::setValues(zorba::Item& aEntry) |
577 | 211 | { | 242 | { |
581 | 212 | theEntryPath = aEntry.getStringValue(); | 243 | if (aEntry.isJSONItem()) |
579 | 213 | |||
580 | 214 | if (aEntry.isNode()) | ||
582 | 215 | { | 244 | { |
584 | 216 | Item lAttr; | 245 | Item lKey; |
585 | 217 | 246 | ||
589 | 218 | Iterator_t lAttrIter = aEntry.getAttributes(); | 247 | Iterator_t lKeyIter = aEntry.getObjectKeys(); |
590 | 219 | lAttrIter->open(); | 248 | lKeyIter->open(); |
591 | 220 | while (lAttrIter->next(lAttr)) | 249 | while (lKeyIter->next(lKey)) |
592 | 221 | { | 250 | { |
595 | 222 | Item lAttrName; | 251 | Item lKeyValue; |
596 | 223 | lAttr.getNodeName(lAttrName); | 252 | lKeyValue = aEntry.getObjectValue(lKey.getStringValue()); |
597 | 224 | 253 | ||
601 | 225 | if(lAttrName.getLocalName() == "type") | 254 | if(lKey.getStringValue() == ArchiveModule::getGlobalItems(ArchiveModule::NAME).getStringValue()) |
602 | 226 | { | 255 | { |
603 | 227 | String filetype = lAttr.getStringValue(); | 256 | theEntryPath = lKeyValue.getStringValue(); |
604 | 257 | } | ||
605 | 258 | else if(lKey.getStringValue() == ArchiveModule::getGlobalItems(ArchiveModule::TYPE).getStringValue()) | ||
606 | 259 | { | ||
607 | 260 | String filetype = lKeyValue.getStringValue(); | ||
608 | 228 | if(filetype == "directory") | 261 | if(filetype == "directory") |
609 | 229 | { | 262 | { |
610 | 230 | theEntryType = directory; | 263 | theEntryType = directory; |
611 | 231 | } | 264 | } |
612 | 232 | } | 265 | } |
614 | 233 | else if (lAttrName.getLocalName() == "last-modified") | 266 | else if (lKey.getStringValue() == ArchiveModule::getGlobalItems(ArchiveModule::LAST_MODIFIED).getStringValue()) |
615 | 234 | { | 267 | { |
617 | 235 | ArchiveModule::parseDateTimeItem(lAttr, theLastModified); | 268 | ArchiveModule::parseDateTimeItem(lKeyValue, theLastModified); |
618 | 236 | } | 269 | } |
620 | 237 | else if (lAttrName.getLocalName() == "encoding") | 270 | else if (lKey.getStringValue() == ArchiveModule::getGlobalItems(ArchiveModule::ENCODING).getStringValue()) |
621 | 238 | { | 271 | { |
623 | 239 | theEncoding = lAttr.getStringValue(); | 272 | theEncoding = lKeyValue.getStringValue(); |
624 | 240 | std::transform( | 273 | std::transform( |
625 | 241 | theEncoding.begin(), theEncoding.end(), | 274 | theEncoding.begin(), theEncoding.end(), |
626 | 242 | theEncoding.begin(), ::toupper); | 275 | theEncoding.begin(), ::toupper); |
627 | @@ -245,19 +278,24 @@ | |||
628 | 245 | std::ostringstream lMsg; | 278 | std::ostringstream lMsg; |
629 | 246 | lMsg << theEncoding << ": unsupported encoding"; | 279 | lMsg << theEncoding << ": unsupported encoding"; |
630 | 247 | 280 | ||
632 | 248 | throwError("ARCH0004", lMsg.str().c_str()); | 281 | throwError(ERROR_INVALID_ENCODING, lMsg.str().c_str()); |
633 | 249 | } | 282 | } |
634 | 250 | } | 283 | } |
636 | 251 | else if (lAttrName.getLocalName() == "compression") | 284 | else if (lKey.getStringValue() == ArchiveModule::getGlobalItems(ArchiveModule::COMPRESSION).getStringValue()) |
637 | 252 | { | 285 | { |
639 | 253 | theCompression = lAttr.getStringValue(); | 286 | theCompression = lKeyValue.getStringValue(); |
640 | 254 | std::transform( | 287 | std::transform( |
641 | 255 | theCompression.begin(), | 288 | theCompression.begin(), |
642 | 256 | theCompression.end(), | 289 | theCompression.end(), |
643 | 257 | theCompression.begin(), ::toupper); | 290 | theCompression.begin(), ::toupper); |
644 | 258 | } | 291 | } |
645 | 292 | else if (lKey.getStringValue() == ArchiveModule::getGlobalItems(ArchiveModule::SIZE).getStringValue()) | ||
646 | 293 | { | ||
647 | 294 | theSize = lKeyValue.getLongValue(); | ||
648 | 295 | } | ||
649 | 259 | } | 296 | } |
651 | 260 | } | 297 | } else |
652 | 298 | theEntryPath = aEntry.getStringValue(); | ||
653 | 261 | } | 299 | } |
654 | 262 | 300 | ||
655 | 263 | /******************** | 301 | /******************** |
656 | @@ -281,66 +319,67 @@ | |||
657 | 281 | void | 319 | void |
658 | 282 | ArchiveFunction::ArchiveOptions::setValues(Item& aOptions) | 320 | ArchiveFunction::ArchiveOptions::setValues(Item& aOptions) |
659 | 283 | { | 321 | { |
720 | 284 | Item lOption; | 322 | if(aOptions.isJSONItem()) |
721 | 285 | 323 | { | |
722 | 286 | Iterator_t lOptionIter = aOptions.getChildren(); | 324 | Item lOptionKey; |
723 | 287 | lOptionIter->open(); | 325 | Iterator_t lKeyIter = aOptions.getObjectKeys(); |
724 | 288 | 326 | lKeyIter->open(); | |
725 | 289 | while (lOptionIter->next(lOption)) | 327 | |
726 | 290 | { | 328 | while (lKeyIter->next(lOptionKey)) |
727 | 291 | Item lOptionName; | 329 | { |
728 | 292 | lOption.getNodeName(lOptionName); | 330 | Item lOptionValue; |
729 | 293 | 331 | lOptionValue = aOptions.getObjectValue(lOptionKey.getStringValue()); | |
730 | 294 | if (lOptionName.getLocalName() == "compression") | 332 | |
731 | 295 | { | 333 | if (lOptionKey.getStringValue() == ArchiveModule::getGlobalItems(ArchiveModule::COMPRESSION).getStringValue()) |
732 | 296 | theCompression = lOption.getStringValue().c_str(); | 334 | { |
733 | 297 | std::transform( | 335 | theCompression = lOptionValue.getStringValue().c_str(); |
734 | 298 | theCompression.begin(), | 336 | std::transform( |
735 | 299 | theCompression.end(), | 337 | theCompression.begin(), |
736 | 300 | theCompression.begin(), ::toupper); | 338 | theCompression.end(), |
737 | 301 | } | 339 | theCompression.begin(), ::toupper); |
738 | 302 | else if (lOptionName.getLocalName() == "format") | 340 | } |
739 | 303 | { | 341 | else if (lOptionKey.getStringValue() == ArchiveModule::getGlobalItems(ArchiveModule::FORMAT).getStringValue()) |
740 | 304 | theFormat = lOption.getStringValue().c_str(); | 342 | { |
741 | 305 | std::transform( | 343 | theFormat = lOptionValue.getStringValue().c_str(); |
742 | 306 | theFormat.begin(), | 344 | std::transform( |
743 | 307 | theFormat.end(), | 345 | theFormat.begin(), |
744 | 308 | theFormat.begin(), ::toupper); | 346 | theFormat.end(), |
745 | 309 | } | 347 | theFormat.begin(), ::toupper); |
746 | 310 | else if (lOptionName.getLocalName() == "skip-extra-attributes") | 348 | } |
747 | 311 | { | 349 | else if (lOptionKey.getStringValue() == "skip-extra-attributes") |
748 | 312 | theSkipExtraAttrs = lOption.getStringValue() == "true" ? true : false; | 350 | { |
749 | 313 | } | 351 | theSkipExtraAttrs = lOptionValue.getStringValue() == "true" ? true : false; |
750 | 314 | } | 352 | } |
751 | 315 | if (theFormat == "ZIP") | 353 | } |
752 | 316 | { | 354 | if (theFormat == "ZIP") |
753 | 317 | if (theCompression != "STORE" && theCompression != "DEFLATE" && theCompression != "NONE") | 355 | { |
754 | 318 | { | 356 | if (theCompression != "STORE" && theCompression != "DEFLATE" && theCompression != "NONE") |
755 | 319 | std::ostringstream lMsg; | 357 | { |
756 | 320 | lMsg | 358 | std::ostringstream lMsg; |
757 | 321 | << theCompression | 359 | lMsg |
758 | 322 | << ": compression algorithm not supported for ZIP format (required: deflate, store)"; | 360 | << theCompression |
759 | 323 | throwError("ARCH0002", lMsg.str().c_str()); | 361 | << ": compression algorithm not supported for ZIP format (required: deflate, store)"; |
760 | 324 | } | 362 | throwError(ERROR_INVALID_OPTIONS, lMsg.str().c_str()); |
761 | 325 | } | 363 | } |
762 | 326 | if (theFormat == "TAR") | 364 | } |
763 | 327 | { | 365 | if (theFormat == "TAR") |
764 | 328 | if (theCompression != "GZIP" | 366 | { if (theCompression != "GZIP" |
765 | 329 | #ifndef WIN32 | 367 | #ifndef WIN32 |
766 | 330 | && theCompression != "BZIP2" | 368 | && theCompression != "BZIP2" |
767 | 331 | && theCompression != "LZMA" | 369 | && theCompression != "LZMA" |
768 | 332 | #endif | 370 | #endif |
769 | 333 | ) | 371 | ) |
770 | 334 | { | 372 | { |
771 | 335 | std::ostringstream lMsg; | 373 | std::ostringstream lMsg; |
772 | 336 | lMsg | 374 | lMsg |
773 | 337 | << theCompression | 375 | << theCompression |
774 | 338 | << ": compression algorithm not supported for TAR format (required: gzip" | 376 | << ": compression algorithm not supported for TAR format (required: gzip" |
775 | 339 | #ifndef WIN32 | 377 | #ifndef WIN32 |
776 | 340 | << ", bzip2, lzma" | 378 | << ", bzip2, lzma" |
777 | 341 | #endif | 379 | #endif |
778 | 342 | << ")"; | 380 | << ")"; |
779 | 343 | throwError("ARCH0002", lMsg.str().c_str()); | 381 | throwError(ERROR_INVALID_OPTIONS, lMsg.str().c_str()); |
780 | 382 | } | ||
781 | 344 | } | 383 | } |
782 | 345 | } | 384 | } |
783 | 346 | } | 385 | } |
784 | @@ -550,7 +589,7 @@ | |||
785 | 550 | 589 | ||
786 | 551 | if (!theArchive) | 590 | if (!theArchive) |
787 | 552 | ArchiveFunction::throwError( | 591 | ArchiveFunction::throwError( |
789 | 553 | "ARCH9999", "internal error (couldn't create archive)"); | 592 | ERROR_CORRUPTED_ARCHIVE, "internal error (couldn't create archive)"); |
790 | 554 | 593 | ||
791 | 555 | setOptions(aOptions); | 594 | setOptions(aOptions); |
792 | 556 | } | 595 | } |
793 | @@ -572,7 +611,7 @@ | |||
794 | 572 | std::ostringstream lMsg; | 611 | std::ostringstream lMsg; |
795 | 573 | lMsg << "number of entries (" << aEntries.size() | 612 | lMsg << "number of entries (" << aEntries.size() |
796 | 574 | << ") doesn't match number of content arguments (" << i << ")"; | 613 | << ") doesn't match number of content arguments (" << i << ")"; |
798 | 575 | throwError("ARCH0001", lMsg.str().c_str()); | 614 | throwError(ERROR_ENTRY_COUNT_MISMATCH, lMsg.str().c_str()); |
799 | 576 | } | 615 | } |
800 | 577 | } | 616 | } |
801 | 578 | 617 | ||
802 | @@ -587,7 +626,7 @@ | |||
803 | 587 | std::ostringstream lMsg; | 626 | std::ostringstream lMsg; |
804 | 588 | lMsg << "number of entries (" << aEntries.size() | 627 | lMsg << "number of entries (" << aEntries.size() |
805 | 589 | << ") less than number of content arguments"; | 628 | << ") less than number of content arguments"; |
807 | 590 | throwError("ARCH0001", lMsg.str().c_str()); | 629 | throwError(ERROR_ENTRY_COUNT_MISMATCH, lMsg.str().c_str()); |
808 | 591 | } | 630 | } |
809 | 592 | 631 | ||
810 | 593 | aFiles->close(); | 632 | aFiles->close(); |
811 | @@ -601,7 +640,6 @@ | |||
812 | 601 | 640 | ||
813 | 602 | archive_entry_set_pathname(theEntry, aEntry.getEntryPath().c_str()); | 641 | archive_entry_set_pathname(theEntry, aEntry.getEntryPath().c_str()); |
814 | 603 | archive_entry_set_mtime(theEntry, aEntry.getLastModified(), 0); | 642 | archive_entry_set_mtime(theEntry, aEntry.getLastModified(), 0); |
815 | 604 | // TODO: modified to allow the creation of empty directories | ||
816 | 605 | if(aEntry.getEntryType() == ArchiveEntry::regular){ | 643 | if(aEntry.getEntryType() == ArchiveEntry::regular){ |
817 | 606 | archive_entry_set_filetype(theEntry, AE_IFREG); | 644 | archive_entry_set_filetype(theEntry, AE_IFREG); |
818 | 607 | lDeleteStream = getStream( | 645 | lDeleteStream = getStream( |
819 | @@ -626,7 +664,7 @@ | |||
820 | 626 | #ifndef ZORBA_LIBARCHIVE_HAVE_SET_COMPRESSION | 664 | #ifndef ZORBA_LIBARCHIVE_HAVE_SET_COMPRESSION |
821 | 627 | std::ostringstream lMsg; | 665 | std::ostringstream lMsg; |
822 | 628 | lMsg << lNextCompString << ": setting different compression algorithms for each entry is not supported by the used version of libarchive"; | 666 | lMsg << lNextCompString << ": setting different compression algorithms for each entry is not supported by the used version of libarchive"; |
824 | 629 | throwError("ARCH0099", lMsg.str().c_str()); | 667 | throwError(ERROR_DIFFERENT_COMPRESSIONS_NOT_SUPPORTED, lMsg.str().c_str()); |
825 | 630 | #endif | 668 | #endif |
826 | 631 | } | 669 | } |
827 | 632 | else | 670 | else |
828 | @@ -638,7 +676,7 @@ | |||
829 | 638 | { | 676 | { |
830 | 639 | std::ostringstream lMsg; | 677 | std::ostringstream lMsg; |
831 | 640 | lMsg << lNextCompString << ": compression algorithm not supported for ZIP format (required: deflate, store)"; | 678 | lMsg << lNextCompString << ": compression algorithm not supported for ZIP format (required: deflate, store)"; |
833 | 641 | throwError("ARCH0002", lMsg.str().c_str()); | 679 | throwError(ERROR_INVALID_OPTIONS, lMsg.str().c_str()); |
834 | 642 | } | 680 | } |
835 | 643 | 681 | ||
836 | 644 | #ifdef ZORBA_LIBARCHIVE_HAVE_SET_COMPRESSION | 682 | #ifdef ZORBA_LIBARCHIVE_HAVE_SET_COMPRESSION |
837 | @@ -651,7 +689,7 @@ | |||
838 | 651 | { | 689 | { |
839 | 652 | std::ostringstream lMsg; | 690 | std::ostringstream lMsg; |
840 | 653 | lMsg << aEntry.getCompression() << ": compression attribute only allowed for zip format"; | 691 | lMsg << aEntry.getCompression() << ": compression attribute only allowed for zip format"; |
842 | 654 | throwError("ARCH0099", lMsg.str().c_str()); | 692 | throwError(ERROR_DIFFERENT_COMPRESSIONS_NOT_SUPPORTED, lMsg.str().c_str()); |
843 | 655 | } | 693 | } |
844 | 656 | } | 694 | } |
845 | 657 | 695 | ||
846 | @@ -718,7 +756,7 @@ | |||
847 | 718 | { | 756 | { |
848 | 719 | if (!aLocalName) | 757 | if (!aLocalName) |
849 | 720 | { | 758 | { |
851 | 721 | throwError("ARCH9999", archive_error_string(a)); | 759 | throwError(ERROR_CORRUPTED_ARCHIVE, archive_error_string(a)); |
852 | 722 | } | 760 | } |
853 | 723 | else | 761 | else |
854 | 724 | { | 762 | { |
855 | @@ -781,7 +819,7 @@ | |||
856 | 781 | { | 819 | { |
857 | 782 | std::ostringstream lMsg; | 820 | std::ostringstream lMsg; |
858 | 783 | lMsg << f << ": archive format not supported"; | 821 | lMsg << f << ": archive format not supported"; |
860 | 784 | throwError("ARCH0002", lMsg.str().c_str()); | 822 | throwError(ERROR_INVALID_OPTIONS, lMsg.str().c_str()); |
861 | 785 | } | 823 | } |
862 | 786 | return 0; | 824 | return 0; |
863 | 787 | } | 825 | } |
864 | @@ -817,7 +855,7 @@ | |||
865 | 817 | { | 855 | { |
866 | 818 | std::ostringstream lMsg; | 856 | std::ostringstream lMsg; |
867 | 819 | lMsg << c << ": compression algorithm not supported"; | 857 | lMsg << c << ": compression algorithm not supported"; |
869 | 820 | throwError("ARCH0002", lMsg.str().c_str()); | 858 | throwError(ERROR_INVALID_OPTIONS, lMsg.str().c_str()); |
870 | 821 | } | 859 | } |
871 | 822 | return 0; | 860 | return 0; |
872 | 823 | } | 861 | } |
873 | @@ -897,7 +935,7 @@ | |||
874 | 897 | 935 | ||
875 | 898 | if (!theArchive) | 936 | if (!theArchive) |
876 | 899 | ArchiveFunction::throwError( | 937 | ArchiveFunction::throwError( |
878 | 900 | "ARCH9999", "internal error (couldn't create archive)"); | 938 | ERROR_CORRUPTED_ARCHIVE, "internal error (couldn't create archive)"); |
879 | 901 | 939 | ||
880 | 902 | int lErr = archive_read_support_compression_all(theArchive); | 940 | int lErr = archive_read_support_compression_all(theArchive); |
881 | 903 | ArchiveFunction::checkForError(lErr, 0, theArchive); | 941 | ArchiveFunction::checkForError(lErr, 0, theArchive); |
882 | @@ -1039,15 +1077,6 @@ | |||
883 | 1039 | zorba::Item& aArchive) | 1077 | zorba::Item& aArchive) |
884 | 1040 | : ArchiveIterator(aArchive) | 1078 | : ArchiveIterator(aArchive) |
885 | 1041 | { | 1079 | { |
886 | 1042 | theUntypedQName = theFactory->createQName( | ||
887 | 1043 | "http://www.w3.org/2001/XMLSchema", "untyped"); | ||
888 | 1044 | |||
889 | 1045 | theEntryName = theFactory->createQName( | ||
890 | 1046 | ArchiveModule::getModuleURI(), "entry"); | ||
891 | 1047 | |||
892 | 1048 | theLastModifiedName = theFactory->createQName("", "last-modified"); | ||
893 | 1049 | theUncompressedSizeName = theFactory->createQName("", "size"); | ||
894 | 1050 | theEntryType = theFactory->createQName("", "type"); | ||
895 | 1051 | } | 1080 | } |
896 | 1052 | 1081 | ||
897 | 1053 | bool | 1082 | bool |
898 | @@ -1064,49 +1093,42 @@ | |||
899 | 1064 | ArchiveFunction::checkForError(lErr, 0, theArchive); | 1093 | ArchiveFunction::checkForError(lErr, 0, theArchive); |
900 | 1065 | } | 1094 | } |
901 | 1066 | 1095 | ||
909 | 1067 | Item lNoParent; | 1096 | std::vector<std::pair<zorba::Item, zorba::Item> > lObjectArray; |
910 | 1068 | 1097 | std::pair<zorba::Item, zorba::Item> lElemPair; | |
904 | 1069 | Item lType = theUntypedQName; | ||
905 | 1070 | |||
906 | 1071 | // create entry element | ||
907 | 1072 | aRes = theFactory->createElementNode( | ||
908 | 1073 | lNoParent, theEntryName, lType, true, false, NsBindings()); | ||
911 | 1074 | 1098 | ||
912 | 1075 | // create text content (i.e. path name) | 1099 | // create text content (i.e. path name) |
913 | 1076 | String lName = archive_entry_pathname(lEntry); | 1100 | String lName = archive_entry_pathname(lEntry); |
916 | 1077 | Item lNameItem = theFactory->createString(lName); | 1101 | lElemPair = std::make_pair<zorba::Item, zorba::Item>(ArchiveModule::getGlobalItems(ArchiveModule::NAME), |
917 | 1078 | theFactory->assignElementTypedValue(aRes, lNameItem); | 1102 | theFactory->createString(lName)); |
918 | 1103 | lObjectArray.push_back(lElemPair); | ||
919 | 1079 | 1104 | ||
920 | 1080 | // create size attr if the value is set in the archive | 1105 | // create size attr if the value is set in the archive |
921 | 1081 | if (archive_entry_size_is_set(lEntry)) | 1106 | if (archive_entry_size_is_set(lEntry)) |
922 | 1082 | { | 1107 | { |
923 | 1083 | long long lSize = archive_entry_size(lEntry); | 1108 | long long lSize = archive_entry_size(lEntry); |
928 | 1084 | Item lSizeItem = theFactory->createInteger(lSize); | 1109 | lElemPair = std::make_pair<zorba::Item, zorba::Item>(ArchiveModule::getGlobalItems(ArchiveModule::SIZE), |
929 | 1085 | lType = theUntypedQName; | 1110 | theFactory->createInteger(lSize)); |
930 | 1086 | theFactory->createAttributeNode( | 1111 | lObjectArray.push_back(lElemPair); |
927 | 1087 | aRes, theUncompressedSizeName, lType, lSizeItem); | ||
931 | 1088 | } | 1112 | } |
932 | 1089 | 1113 | ||
933 | 1090 | // create last-modified attr if the value is set in the archive | 1114 | // create last-modified attr if the value is set in the archive |
934 | 1091 | if (archive_entry_mtime_is_set(lEntry)) | 1115 | if (archive_entry_mtime_is_set(lEntry)) |
935 | 1092 | { | 1116 | { |
936 | 1093 | time_t lTime = archive_entry_mtime(lEntry); | 1117 | time_t lTime = archive_entry_mtime(lEntry); |
942 | 1094 | Item lModifiedItem = ArchiveModule::createDateTimeItem(lTime); | 1118 | lElemPair = std::make_pair<zorba::Item, zorba::Item>(ArchiveModule::getGlobalItems(ArchiveModule::LAST_MODIFIED), |
943 | 1095 | 1119 | ArchiveModule::createDateTimeItem(lTime)); | |
944 | 1096 | lType = theUntypedQName; | 1120 | lObjectArray.push_back(lElemPair); |
940 | 1097 | theFactory->createAttributeNode( | ||
941 | 1098 | aRes, theLastModifiedName, lType, lModifiedItem); | ||
945 | 1099 | } | 1121 | } |
946 | 1100 | 1122 | ||
948 | 1101 | Item lEntryType; | 1123 | std::string lEntryType; |
949 | 1102 | if(archive_entry_filetype(lEntry) == AE_IFDIR) | 1124 | if(archive_entry_filetype(lEntry) == AE_IFDIR) |
950 | 1103 | { | 1125 | { |
951 | 1104 | // this entry is a directory | 1126 | // this entry is a directory |
953 | 1105 | lEntryType = theFactory->createString("directory"); | 1127 | lEntryType = "directory"; |
954 | 1106 | } | 1128 | } |
955 | 1107 | else if(archive_entry_filetype(lEntry) == AE_IFREG) | 1129 | else if(archive_entry_filetype(lEntry) == AE_IFREG) |
956 | 1108 | { | 1130 | { |
958 | 1109 | lEntryType = theFactory->createString("regular"); | 1131 | lEntryType = "regular"; |
959 | 1110 | } | 1132 | } |
960 | 1111 | else | 1133 | else |
961 | 1112 | { | 1134 | { |
962 | @@ -1114,14 +1136,16 @@ | |||
963 | 1114 | // for the time being don't do anything | 1136 | // for the time being don't do anything |
964 | 1115 | } | 1137 | } |
965 | 1116 | 1138 | ||
969 | 1117 | lType = theUntypedQName; | 1139 | lElemPair = std::make_pair<zorba::Item, zorba::Item>(ArchiveModule::getGlobalItems(ArchiveModule::TYPE), |
970 | 1118 | theFactory->createAttributeNode( | 1140 | theFactory->createString(lEntryType)); |
971 | 1119 | aRes, theEntryType, lType, lEntryType); | 1141 | lObjectArray.push_back(lElemPair); |
972 | 1120 | 1142 | ||
973 | 1121 | // skip to the next entry and raise an error if that fails | 1143 | // skip to the next entry and raise an error if that fails |
974 | 1122 | lErr = archive_read_data_skip(theArchive); | 1144 | lErr = archive_read_data_skip(theArchive); |
975 | 1123 | ArchiveFunction::checkForError(lErr, 0, theArchive); | 1145 | ArchiveFunction::checkForError(lErr, 0, theArchive); |
976 | 1124 | 1146 | ||
977 | 1147 | aRes = theFactory->createJSONObject(lObjectArray); | ||
978 | 1148 | |||
979 | 1125 | return true; | 1149 | return true; |
980 | 1126 | } | 1150 | } |
981 | 1127 | 1151 | ||
982 | @@ -1190,7 +1214,7 @@ | |||
983 | 1190 | std::ostringstream lMsg; | 1214 | std::ostringstream lMsg; |
984 | 1191 | lMsg << lEncoding << ": unsupported encoding"; | 1215 | lMsg << lEncoding << ": unsupported encoding"; |
985 | 1192 | 1216 | ||
987 | 1193 | throwError("ARCH0004", lMsg.str().c_str()); | 1217 | throwError(ERROR_INVALID_ENCODING, lMsg.str().c_str()); |
988 | 1194 | } | 1218 | } |
989 | 1195 | } | 1219 | } |
990 | 1196 | 1220 | ||
991 | @@ -1363,6 +1387,11 @@ | |||
992 | 1363 | return ItemSequence_t(new OptionsItemSequence(lArchive)); | 1387 | return ItemSequence_t(new OptionsItemSequence(lArchive)); |
993 | 1364 | } | 1388 | } |
994 | 1365 | 1389 | ||
995 | 1390 | OptionsFunction::OptionsItemSequence::OptionsIterator::OptionsIterator(Item &aArchive) | ||
996 | 1391 | :ArchiveIterator(aArchive) | ||
997 | 1392 | { | ||
998 | 1393 | } | ||
999 | 1394 | |||
1000 | 1366 | bool | 1395 | bool |
1001 | 1367 | OptionsFunction::OptionsItemSequence::OptionsIterator::next( | 1396 | OptionsFunction::OptionsItemSequence::OptionsIterator::next( |
1002 | 1368 | zorba::Item& aRes) | 1397 | zorba::Item& aRes) |
1003 | @@ -1372,6 +1401,9 @@ | |||
1004 | 1372 | lExhausted = true; | 1401 | lExhausted = true; |
1005 | 1373 | 1402 | ||
1006 | 1374 | struct archive_entry *lEntry; | 1403 | struct archive_entry *lEntry; |
1007 | 1404 | typedef std::pair<zorba::Item, zorba::Item> tArrElemt; | ||
1008 | 1405 | tArrElemt lElemt; | ||
1009 | 1406 | std::vector<tArrElemt> lJSONObject; | ||
1010 | 1375 | 1407 | ||
1011 | 1376 | // to get the format, we need to peek into the first header | 1408 | // to get the format, we need to peek into the first header |
1012 | 1377 | int lErr = archive_read_next_header(theArchive, &lEntry); | 1409 | int lErr = archive_read_next_header(theArchive, &lEntry); |
1013 | @@ -1391,33 +1423,15 @@ | |||
1014 | 1391 | lCompression = "DEFLATE"; | 1423 | lCompression = "DEFLATE"; |
1015 | 1392 | } | 1424 | } |
1016 | 1393 | 1425 | ||
1044 | 1394 | zorba::Item lUntypedQName = theFactory->createQName( | 1426 | lElemt = std::make_pair<zorba::Item, zorba::Item>(ArchiveModule::getGlobalItems(ArchiveModule::FORMAT), |
1045 | 1395 | "http://www.w3.org/2001/XMLSchema", "untyped"); | 1427 | theFactory->createString(lFormat)); |
1046 | 1396 | zorba::Item lTmpQName = lUntypedQName; | 1428 | lJSONObject.push_back(lElemt); |
1047 | 1397 | 1429 | ||
1048 | 1398 | zorba::Item lOptionsQName = theFactory->createQName( | 1430 | lElemt = std::make_pair<zorba::Item, zorba::Item>(ArchiveModule::getGlobalItems(ArchiveModule::COMPRESSION), |
1049 | 1399 | ArchiveModule::getModuleURI(), "options"); | 1431 | theFactory->createString(lCompression)); |
1050 | 1400 | 1432 | lJSONObject.push_back(lElemt); | |
1051 | 1401 | zorba::Item lFormatQName = theFactory->createQName( | 1433 | |
1052 | 1402 | ArchiveModule::getModuleURI(), "format"); | 1434 | aRes = theFactory->createJSONObject(lJSONObject); |
1026 | 1403 | |||
1027 | 1404 | zorba::Item lCompressionQName = theFactory->createQName( | ||
1028 | 1405 | ArchiveModule::getModuleURI(), "compression"); | ||
1029 | 1406 | |||
1030 | 1407 | zorba::Item lNoParent; | ||
1031 | 1408 | aRes = theFactory->createElementNode( | ||
1032 | 1409 | lNoParent, lOptionsQName, lTmpQName, true, false, NsBindings()); | ||
1033 | 1410 | |||
1034 | 1411 | lTmpQName = lUntypedQName; | ||
1035 | 1412 | zorba::Item lFormatItem = theFactory->createElementNode( | ||
1036 | 1413 | aRes, lFormatQName, lTmpQName, true, false, NsBindings()); | ||
1037 | 1414 | |||
1038 | 1415 | lTmpQName = lUntypedQName; | ||
1039 | 1416 | zorba::Item lCompressionItem = theFactory->createElementNode( | ||
1040 | 1417 | aRes, lCompressionQName, lTmpQName, true, false, NsBindings()); | ||
1041 | 1418 | |||
1042 | 1419 | theFactory->createTextNode(lFormatItem, lFormat); | ||
1043 | 1420 | theFactory->createTextNode(lCompressionItem, lCompression); | ||
1053 | 1421 | 1435 | ||
1054 | 1422 | return true; | 1436 | return true; |
1055 | 1423 | } | 1437 | } |
1056 | @@ -1647,6 +1661,7 @@ | |||
1057 | 1647 | } | 1661 | } |
1058 | 1648 | // else? if the entry represents a directory what are we | 1662 | // else? if the entry represents a directory what are we |
1059 | 1649 | // going to return?? | 1663 | // going to return?? |
1060 | 1664 | // answer: nothing, the directory will have no contents at all | ||
1061 | 1650 | 1665 | ||
1062 | 1651 | return true; | 1666 | return true; |
1063 | 1652 | } | 1667 | } |
1064 | 1653 | 1668 | ||
1065 | === modified file 'src/archive_module.xq.src/archive_module.h' | |||
1066 | --- src/archive_module.xq.src/archive_module.h 2013-02-18 22:00:20 +0000 | |||
1067 | +++ src/archive_module.xq.src/archive_module.h 2013-07-29 19:28:26 +0000 | |||
1068 | @@ -52,8 +52,29 @@ | |||
1069 | 52 | 52 | ||
1070 | 53 | FuncMap_t theFunctions; | 53 | FuncMap_t theFunctions; |
1071 | 54 | 54 | ||
1072 | 55 | static zorba::Item globalFormatKey; | ||
1073 | 56 | static zorba::Item globalCompressionKey; | ||
1074 | 57 | static zorba::Item globalNameKey; | ||
1075 | 58 | static zorba::Item globalTypeKey; | ||
1076 | 59 | static zorba::Item globalSizeKey; | ||
1077 | 60 | static zorba::Item globalLastModifiedKey; | ||
1078 | 61 | static zorba::Item globalEncodingKey; | ||
1079 | 62 | |||
1080 | 55 | public: | 63 | public: |
1081 | 56 | 64 | ||
1082 | 65 | enum GLOBAL_ITEMS { FORMAT, COMPRESSION, NAME, TYPE, SIZE, LAST_MODIFIED, ENCODING }; | ||
1083 | 66 | |||
1084 | 67 | ArchiveModule() | ||
1085 | 68 | { | ||
1086 | 69 | globalFormatKey = Zorba::getInstance(0)->getItemFactory()->createString("format"); | ||
1087 | 70 | globalCompressionKey = Zorba::getInstance(0)->getItemFactory()->createString("compression"); | ||
1088 | 71 | globalNameKey = Zorba::getInstance(0)->getItemFactory()->createString("name"); | ||
1089 | 72 | globalTypeKey = Zorba::getInstance(0)->getItemFactory()->createString("type"); | ||
1090 | 73 | globalSizeKey = Zorba::getInstance(0)->getItemFactory()->createString("size"); | ||
1091 | 74 | globalLastModifiedKey = Zorba::getInstance(0)->getItemFactory()->createString("last-modified"); | ||
1092 | 75 | globalEncodingKey = Zorba::getInstance(0)->getItemFactory()->createString("encoding"); | ||
1093 | 76 | } | ||
1094 | 77 | |||
1095 | 57 | virtual ~ArchiveModule(); | 78 | virtual ~ArchiveModule(); |
1096 | 58 | 79 | ||
1097 | 59 | virtual zorba::String | 80 | virtual zorba::String |
1098 | @@ -71,7 +92,7 @@ | |||
1099 | 71 | } | 92 | } |
1100 | 72 | 93 | ||
1101 | 73 | static zorba::String | 94 | static zorba::String |
1103 | 74 | getModuleURI() { return "http://www.zorba-xquery.com/modules/archive"; } | 95 | getModuleURI() { return "http://zorba.io/modules/archive"; } |
1104 | 75 | 96 | ||
1105 | 76 | static zorba::Item | 97 | static zorba::Item |
1106 | 77 | createDateTimeItem(time_t&); | 98 | createDateTimeItem(time_t&); |
1107 | @@ -79,6 +100,7 @@ | |||
1108 | 79 | static void | 100 | static void |
1109 | 80 | parseDateTimeItem(const zorba::Item& i, time_t&); | 101 | parseDateTimeItem(const zorba::Item& i, time_t&); |
1110 | 81 | 102 | ||
1111 | 103 | static zorba::Item& getGlobalItems(enum GLOBAL_ITEMS g); | ||
1112 | 82 | }; | 104 | }; |
1113 | 83 | 105 | ||
1114 | 84 | 106 | ||
1115 | @@ -602,8 +624,7 @@ | |||
1116 | 602 | class OptionsIterator : public ArchiveIterator | 624 | class OptionsIterator : public ArchiveIterator |
1117 | 603 | { | 625 | { |
1118 | 604 | public: | 626 | public: |
1121 | 605 | OptionsIterator(zorba::Item& aArchive) | 627 | OptionsIterator(zorba::Item& aArchive); |
1120 | 606 | : ArchiveIterator(aArchive) {} | ||
1122 | 607 | 628 | ||
1123 | 608 | virtual ~OptionsIterator() {} | 629 | virtual ~OptionsIterator() {} |
1124 | 609 | 630 | ||
1125 | @@ -755,7 +776,6 @@ | |||
1126 | 755 | ArchiveOptions& theOptions; | 776 | ArchiveOptions& theOptions; |
1127 | 756 | }; | 777 | }; |
1128 | 757 | 778 | ||
1129 | 758 | //public: | ||
1130 | 759 | DeleteItemSequence(zorba::Item& aArchive) | 779 | DeleteItemSequence(zorba::Item& aArchive) |
1131 | 760 | : ExtractFunction::ExtractItemSequence(aArchive, false) {} | 780 | : ExtractFunction::ExtractItemSequence(aArchive, false) {} |
1132 | 761 | 781 | ||
1133 | 762 | 782 | ||
1134 | === modified file 'test/ExpQueryResults/entries_01.xml.res' | |||
1135 | --- test/ExpQueryResults/entries_01.xml.res 2012-09-17 17:56:29 +0000 | |||
1136 | +++ test/ExpQueryResults/entries_01.xml.res 2013-07-29 19:28:26 +0000 | |||
1137 | @@ -1,2 +1,1 @@ | |||
1138 | 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
1139 | 2 | <entry xmlns="http://www.zorba-xquery.com/modules/archive" size="0" last-modified="2012-06-15T20:11:09Z" type="directory">dir1/</entry><entry xmlns="http://www.zorba-xquery.com/modules/archive" size="11" last-modified="2012-06-15T20:11:09Z" type="regular">dir1/file1</entry><entry xmlns="http://www.zorba-xquery.com/modules/archive" size="11" last-modified="2012-06-15T20:11:03Z" type="regular">dir1/file2</entry><entry xmlns="http://www.zorba-xquery.com/modules/archive" size="0" last-modified="2012-06-15T20:10:51Z" type="directory">dir2/</entry><entry xmlns="http://www.zorba-xquery.com/modules/archive" size="6" last-modified="2012-06-15T20:10:47Z" type="regular">file1</entry> | ||
1140 | 3 | \ No newline at end of file | 1 | \ No newline at end of file |
1141 | 2 | { "name" : "dir1/", "size" : 0, "last-modified" : "2012-06-15T20:11:09Z", "type" : "directory" }{ "name" : "dir1/file1", "size" : 11, "last-modified" : "2012-06-15T20:11:09Z", "type" : "regular" }{ "name" : "dir1/file2", "size" : 11, "last-modified" : "2012-06-15T20:11:03Z", "type" : "regular" }{ "name" : "dir2/", "size" : 0, "last-modified" : "2012-06-15T20:10:51Z", "type" : "directory" }{ "name" : "file1", "size" : 6, "last-modified" : "2012-06-15T20:10:47Z", "type" : "regular" } | ||
1142 | 4 | \ No newline at end of file | 3 | \ No newline at end of file |
1143 | 5 | 4 | ||
1144 | === modified file 'test/ExpQueryResults/entries_02.xml.res' | |||
1145 | --- test/ExpQueryResults/entries_02.xml.res 2012-09-17 17:56:29 +0000 | |||
1146 | +++ test/ExpQueryResults/entries_02.xml.res 2013-07-29 19:28:26 +0000 | |||
1147 | @@ -1,2 +1,1 @@ | |||
1148 | 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
1149 | 2 | <entry xmlns="http://www.zorba-xquery.com/modules/archive" size="0" last-modified="2012-06-15T20:11:09Z" type="directory">dir1/</entry><entry xmlns="http://www.zorba-xquery.com/modules/archive" size="11" last-modified="2012-06-15T20:11:09Z" type="regular">dir1/file1</entry><entry xmlns="http://www.zorba-xquery.com/modules/archive" size="11" last-modified="2012-06-15T20:11:03Z" type="regular">dir1/file2</entry><entry xmlns="http://www.zorba-xquery.com/modules/archive" size="0" last-modified="2012-06-15T20:10:51Z" type="directory">dir2/</entry><entry xmlns="http://www.zorba-xquery.com/modules/archive" size="6" last-modified="2012-06-15T20:10:47Z" type="regular">file1</entry> | ||
1150 | 3 | \ No newline at end of file | 1 | \ No newline at end of file |
1151 | 2 | { "name" : "dir1/", "size" : 0, "last-modified" : "2012-06-15T20:11:09Z", "type" : "directory" }{ "name" : "dir1/file1", "size" : 11, "last-modified" : "2012-06-15T20:11:09Z", "type" : "regular" }{ "name" : "dir1/file2", "size" : 11, "last-modified" : "2012-06-15T20:11:03Z", "type" : "regular" }{ "name" : "dir2/", "size" : 0, "last-modified" : "2012-06-15T20:10:51Z", "type" : "directory" }{ "name" : "file1", "size" : 6, "last-modified" : "2012-06-15T20:10:47Z", "type" : "regular" } | ||
1152 | 4 | \ No newline at end of file | 3 | \ No newline at end of file |
1153 | 5 | 4 | ||
1154 | === modified file 'test/ExpQueryResults/entries_03.xml.res' | |||
1155 | --- test/ExpQueryResults/entries_03.xml.res 2012-09-17 17:56:29 +0000 | |||
1156 | +++ test/ExpQueryResults/entries_03.xml.res 2013-07-29 19:28:26 +0000 | |||
1157 | @@ -1,1 +1,1 @@ | |||
1159 | 1 | <entry xmlns="http://www.zorba-xquery.com/modules/archive" size="0" last-modified="2012-06-15T20:11:09Z" type="directory">dir1/</entry><entry xmlns="http://www.zorba-xquery.com/modules/archive" size="11" last-modified="2012-06-15T20:11:09Z" type="regular">dir1/file1</entry><entry xmlns="http://www.zorba-xquery.com/modules/archive" size="11" last-modified="2012-06-15T20:11:03Z" type="regular">dir1/file2</entry><entry xmlns="http://www.zorba-xquery.com/modules/archive" size="0" last-modified="2012-06-15T20:10:51Z" type="directory">dir2/</entry><entry xmlns="http://www.zorba-xquery.com/modules/archive" size="6" last-modified="2012-06-15T20:10:47Z" type="regular">file1</entry> | 1 | { "name" : "dir1/", "size" : 0, "last-modified" : "2012-06-15T20:11:09Z", "type" : "directory" }{ "name" : "dir1/file1", "size" : 11, "last-modified" : "2012-06-15T20:11:09Z", "type" : "regular" }{ "name" : "dir1/file2", "size" : 11, "last-modified" : "2012-06-15T20:11:03Z", "type" : "regular" }{ "name" : "dir2/", "size" : 0, "last-modified" : "2012-06-15T20:10:51Z", "type" : "directory" }{ "name" : "file1", "size" : 6, "last-modified" : "2012-06-15T20:10:47Z", "type" : "regular" } |
1160 | 2 | \ No newline at end of file | 2 | \ No newline at end of file |
1161 | 3 | 3 | ||
1162 | === modified file 'test/ExpQueryResults/options_01.xml.res' | |||
1163 | --- test/ExpQueryResults/options_01.xml.res 2012-08-03 21:54:38 +0000 | |||
1164 | +++ test/ExpQueryResults/options_01.xml.res 2013-07-29 19:28:26 +0000 | |||
1165 | @@ -1,2 +1,1 @@ | |||
1166 | 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
1167 | 2 | <options xmlns="http://www.zorba-xquery.com/modules/archive"><format>ZIP</format><compression>DEFLATE</compression></options><options xmlns="http://www.zorba-xquery.com/modules/archive"><format>TAR</format><compression>GZIP</compression></options> | ||
1168 | 3 | \ No newline at end of file | 1 | \ No newline at end of file |
1169 | 2 | { "format" : "ZIP", "compression" : "DEFLATE" }{ "format" : "TAR", "compression" : "GZIP" } | ||
1170 | 4 | \ No newline at end of file | 3 | \ No newline at end of file |
1171 | 5 | 4 | ||
1172 | === modified file 'test/ExpQueryResults/options_02.xml.res' | |||
1173 | --- test/ExpQueryResults/options_02.xml.res 2012-09-17 18:17:09 +0000 | |||
1174 | +++ test/ExpQueryResults/options_02.xml.res 2013-07-29 19:28:26 +0000 | |||
1175 | @@ -1,2 +1,1 @@ | |||
1176 | 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
1177 | 2 | <options xmlns="http://www.zorba-xquery.com/modules/archive"><format>TAR</format><compression>BZIP2</compression></options> | ||
1178 | 3 | \ No newline at end of file | 1 | \ No newline at end of file |
1179 | 2 | { "format" : "TAR", "compression" : "BZIP2" } | ||
1180 | 4 | \ No newline at end of file | 3 | \ No newline at end of file |
1181 | 5 | 4 | ||
1182 | === modified file 'test/Queries/create_01.xq' | |||
1183 | --- test/Queries/create_01.xq 2012-07-27 03:43:13 +0000 | |||
1184 | +++ test/Queries/create_01.xq 2013-07-29 19:28:26 +0000 | |||
1185 | @@ -1,4 +1,4 @@ | |||
1187 | 1 | import module namespace a = "http://www.zorba-xquery.com/modules/archive"; | 1 | import module namespace a = "http://zorba.io/modules/archive"; |
1188 | 2 | 2 | ||
1189 | 3 | let $foo-content := "<foo/>" | 3 | let $foo-content := "<foo/>" |
1190 | 4 | let $bar-content := "<bar/>" | 4 | let $bar-content := "<bar/>" |
1191 | @@ -8,6 +8,7 @@ | |||
1192 | 8 | ) | 8 | ) |
1193 | 9 | return | 9 | return |
1194 | 10 | string-join( | 10 | string-join( |
1197 | 11 | for $a in a:entries($archive) | 11 | for $name in a:entries($archive)("name") |
1198 | 12 | return a:extract-text($archive, $a/text()) | 12 | return a:extract-text($archive, $name) |
1199 | 13 | ) eq concat($foo-content, $bar-content) | 13 | ) eq concat($foo-content, $bar-content) |
1200 | 14 | |||
1201 | 14 | 15 | ||
1202 | === modified file 'test/Queries/create_02.xq' | |||
1203 | --- test/Queries/create_02.xq 2013-07-17 07:50:04 +0000 | |||
1204 | +++ test/Queries/create_02.xq 2013-07-29 19:28:26 +0000 | |||
1205 | @@ -1,10 +1,10 @@ | |||
1207 | 1 | import module namespace a = "http://www.zorba-xquery.com/modules/archive"; | 1 | import module namespace a = "http://zorba.io/modules/archive"; |
1208 | 2 | import module namespace b = "http://zorba.io/modules/base64"; | 2 | import module namespace b = "http://zorba.io/modules/base64"; |
1209 | 3 | 3 | ||
1210 | 4 | let $foo-content := "<foo/>" | 4 | let $foo-content := "<foo/>" |
1211 | 5 | let $bar-content := xs:base64Binary("5Pb8") | 5 | let $bar-content := xs:base64Binary("5Pb8") |
1212 | 6 | let $archive := a:create( | 6 | let $archive := a:create( |
1214 | 7 | ("foo.xml", <a:entry encoding="ISO-8859-1">bar.xml</a:entry>), | 7 | ("foo.xml", { "encoding" : "ISO-8859-1", "name" : "bar.xml" }), |
1215 | 8 | ($foo-content, $bar-content) | 8 | ($foo-content, $bar-content) |
1216 | 9 | ) | 9 | ) |
1217 | 10 | return | 10 | return |
1218 | 11 | 11 | ||
1219 | === modified file 'test/Queries/create_03.spec' | |||
1220 | --- test/Queries/create_03.spec 2012-07-27 03:43:13 +0000 | |||
1221 | +++ test/Queries/create_03.spec 2013-07-29 19:28:26 +0000 | |||
1222 | @@ -1,1 +1,1 @@ | |||
1224 | 1 | Error: http://www.zorba-xquery.com/modules/archive:ARCH0099 | 1 | Error: http://zorba.io/modules/archive:DIFFERENT-COMPRESSIONS-NOT-SUPPORTED |
1225 | 2 | 2 | ||
1226 | === modified file 'test/Queries/create_03.xq' | |||
1227 | --- test/Queries/create_03.xq 2012-07-27 03:43:13 +0000 | |||
1228 | +++ test/Queries/create_03.xq 2013-07-29 19:28:26 +0000 | |||
1229 | @@ -1,9 +1,10 @@ | |||
1231 | 1 | import module namespace a = "http://www.zorba-xquery.com/modules/archive"; | 1 | import module namespace a = "http://zorba.io/modules/archive"; |
1232 | 2 | 2 | ||
1233 | 3 | let $foo-content := "<foo/>" | 3 | let $foo-content := "<foo/>" |
1234 | 4 | let $bar-content := "<bar/>" | 4 | let $bar-content := "<bar/>" |
1235 | 5 | let $archive := a:create( | 5 | let $archive := a:create( |
1237 | 6 | (<a:entry compression="store">foo.xml</a:entry>, <a:entry compression="deflate">bar.xml</a:entry>), | 6 | ({ "compression" : "store", "name" : "foo.xml" }, |
1238 | 7 | { "compression" : "deflate", "name" : "bar.xml" }), | ||
1239 | 7 | ($foo-content, $bar-content) | 8 | ($foo-content, $bar-content) |
1240 | 8 | ) | 9 | ) |
1241 | 9 | return | 10 | return |
1242 | 10 | 11 | ||
1243 | === modified file 'test/Queries/delete_01.xq' | |||
1244 | --- test/Queries/delete_01.xq 2013-07-17 07:50:04 +0000 | |||
1245 | +++ test/Queries/delete_01.xq 2013-07-29 19:28:26 +0000 | |||
1246 | @@ -1,4 +1,4 @@ | |||
1248 | 1 | import module namespace a = "http://www.zorba-xquery.com/modules/archive"; | 1 | import module namespace a = "http://zorba.io/modules/archive"; |
1249 | 2 | import module namespace b = "http://zorba.io/modules/base64"; | 2 | import module namespace b = "http://zorba.io/modules/base64"; |
1250 | 3 | 3 | ||
1251 | 4 | let $foo-content := "<foo/>" | 4 | let $foo-content := "<foo/>" |
1252 | 5 | 5 | ||
1253 | === modified file 'test/Queries/delete_02.xq' | |||
1254 | --- test/Queries/delete_02.xq 2012-07-27 03:43:13 +0000 | |||
1255 | +++ test/Queries/delete_02.xq 2013-07-29 19:28:26 +0000 | |||
1256 | @@ -1,5 +1,4 @@ | |||
1259 | 1 | import module namespace a = "http://www.zorba-xquery.com/modules/archive"; | 1 | import module namespace a = "http://zorba.io/modules/archive"; |
1258 | 2 | import schema namespace as = "http://www.zorba-xquery.com/modules/archive"; | ||
1260 | 3 | import module namespace f = "http://expath.org/ns/file"; | 2 | import module namespace f = "http://expath.org/ns/file"; |
1261 | 4 | 3 | ||
1262 | 5 | let $a := f:read-binary(resolve-uri("linear-algebra-20120306.epub")) | 4 | let $a := f:read-binary(resolve-uri("linear-algebra-20120306.epub")) |
1263 | 6 | 5 | ||
1264 | === modified file 'test/Queries/delete_03.xq' | |||
1265 | --- test/Queries/delete_03.xq 2012-07-27 03:43:13 +0000 | |||
1266 | +++ test/Queries/delete_03.xq 2013-07-29 19:28:26 +0000 | |||
1267 | @@ -1,12 +1,12 @@ | |||
1269 | 1 | import module namespace a = "http://www.zorba-xquery.com/modules/archive"; | 1 | import module namespace a = "http://zorba.io/modules/archive"; |
1270 | 2 | 2 | ||
1271 | 3 | let $foo-content := "<foo/>" | 3 | let $foo-content := "<foo/>" |
1272 | 4 | let $bar-content := xs:base64Binary("YWJj") | 4 | let $bar-content := xs:base64Binary("YWJj") |
1273 | 5 | let $options := | 5 | let $options := |
1278 | 6 | <a:options> | 6 | { |
1279 | 7 | <a:format>TAR</a:format> | 7 | "format" : "TAR", |
1280 | 8 | <a:compression>GZIP</a:compression> | 8 | "compression" : "GZIP" |
1281 | 9 | </a:options> | 9 | } |
1282 | 10 | let $archive0 := a:create( | 10 | let $archive0 := a:create( |
1283 | 11 | ("foo.xml"), | 11 | ("foo.xml"), |
1284 | 12 | ($foo-content), | 12 | ($foo-content), |
1285 | 13 | 13 | ||
1286 | === modified file 'test/Queries/delete_04.xq' | |||
1287 | --- test/Queries/delete_04.xq 2012-07-27 03:43:13 +0000 | |||
1288 | +++ test/Queries/delete_04.xq 2013-07-29 19:28:26 +0000 | |||
1289 | @@ -1,13 +1,13 @@ | |||
1291 | 1 | import module namespace a = "http://www.zorba-xquery.com/modules/archive"; | 1 | import module namespace a = "http://zorba.io/modules/archive"; |
1292 | 2 | 2 | ||
1293 | 3 | let $foo-content := "<foo/>" | 3 | let $foo-content := "<foo/>" |
1294 | 4 | let $bar-content := xs:base64Binary("YWJj") | 4 | let $bar-content := xs:base64Binary("YWJj") |
1295 | 5 | let $foo2-content := "<foo2/>" | 5 | let $foo2-content := "<foo2/>" |
1296 | 6 | let $options := | 6 | let $options := |
1301 | 7 | <a:options> | 7 | { |
1302 | 8 | <a:format>TAR</a:format> | 8 | "format" : "TAR", |
1303 | 9 | <a:compression>GZIP</a:compression> | 9 | "compression" : "GZIP" |
1304 | 10 | </a:options> | 10 | } |
1305 | 11 | let $archive0 := a:create( | 11 | let $archive0 := a:create( |
1306 | 12 | ("foo.xml"), | 12 | ("foo.xml"), |
1307 | 13 | ($foo-content), | 13 | ($foo-content), |
1308 | 14 | 14 | ||
1309 | === modified file 'test/Queries/dir_01.xq' | |||
1310 | --- test/Queries/dir_01.xq 2012-09-06 20:40:47 +0000 | |||
1311 | +++ test/Queries/dir_01.xq 2013-07-29 19:28:26 +0000 | |||
1312 | @@ -1,10 +1,10 @@ | |||
1314 | 1 | import module namespace a = "http://www.zorba-xquery.com/modules/archive"; | 1 | import module namespace a = "http://zorba.io/modules/archive"; |
1315 | 2 | 2 | ||
1316 | 3 | let $foo-content := "<foo/>" | 3 | let $foo-content := "<foo/>" |
1317 | 4 | let $bar-content := "<bar/>" | 4 | let $bar-content := "<bar/>" |
1318 | 5 | let $archive := a:create( | 5 | let $archive := a:create( |
1320 | 6 | ("foo.xml", "bar.xml", <entry type="directory">dir1</entry>), | 6 | ("foo.xml", "bar.xml", { "type" : "directory", "name" : "dir1" }), |
1321 | 7 | ($foo-content, $bar-content) | 7 | ($foo-content, $bar-content) |
1322 | 8 | ) | 8 | ) |
1323 | 9 | return | 9 | return |
1325 | 10 | for $e in a:entries($archive) return concat($e/text(), ",") | 10 | for $e in a:entries($archive)("name") return concat($e, ",") |
1326 | 11 | 11 | ||
1327 | === modified file 'test/Queries/dir_02.xq' | |||
1328 | --- test/Queries/dir_02.xq 2012-09-06 20:40:47 +0000 | |||
1329 | +++ test/Queries/dir_02.xq 2013-07-29 19:28:26 +0000 | |||
1330 | @@ -1,11 +1,11 @@ | |||
1332 | 1 | import module namespace a = "http://www.zorba-xquery.com/modules/archive"; | 1 | import module namespace a = "http://zorba.io/modules/archive"; |
1333 | 2 | 2 | ||
1334 | 3 | let $foo-content := "<foo/>" | 3 | let $foo-content := "<foo/>" |
1335 | 4 | let $bar-content := "<bar/>" | 4 | let $bar-content := "<bar/>" |
1336 | 5 | let $archive := a:create( | 5 | let $archive := a:create( |
1338 | 6 | ("foo.xml", "bar.xml", <entry type="directory">dir1</entry>), | 6 | ("foo.xml", "bar.xml", { "type" : "directory", "name" : "dir1" }), |
1339 | 7 | ($foo-content, $bar-content) | 7 | ($foo-content, $bar-content) |
1340 | 8 | ) | 8 | ) |
1341 | 9 | let $archive2 := a:delete($archive, "dir1/") | 9 | let $archive2 := a:delete($archive, "dir1/") |
1342 | 10 | return | 10 | return |
1344 | 11 | for $e in a:entries($archive2) return concat($e/text(), ",") | 11 | for $e in a:entries($archive2)("name") return concat($e, ",") |
1345 | 12 | 12 | ||
1346 | === modified file 'test/Queries/dir_03.xq' | |||
1347 | --- test/Queries/dir_03.xq 2012-09-06 20:40:47 +0000 | |||
1348 | +++ test/Queries/dir_03.xq 2013-07-29 19:28:26 +0000 | |||
1349 | @@ -1,13 +1,13 @@ | |||
1351 | 1 | import module namespace a = "http://www.zorba-xquery.com/modules/archive"; | 1 | import module namespace a = "http://zorba.io/modules/archive"; |
1352 | 2 | 2 | ||
1353 | 3 | let $foo-content := "<foo/>" | 3 | let $foo-content := "<foo/>" |
1354 | 4 | let $bar-content := "<bar/>" | 4 | let $bar-content := "<bar/>" |
1355 | 5 | let $archive := a:create( | 5 | let $archive := a:create( |
1357 | 6 | ("foo.xml", "bar.xml", <entry type="directory">dir1</entry>), | 6 | ("foo.xml", "bar.xml", { "type" : "directory", "name" : "dir1" }), |
1358 | 7 | ($foo-content, $bar-content) | 7 | ($foo-content, $bar-content) |
1359 | 8 | ) | 8 | ) |
1360 | 9 | let $archive2 := a:delete($archive, "nonexistent.xml") | 9 | let $archive2 := a:delete($archive, "nonexistent.xml") |
1361 | 10 | let $entries := a:entries($archive) | 10 | let $entries := a:entries($archive) |
1362 | 11 | let $entries2 := a:entries($archive2) | 11 | let $entries2 := a:entries($archive2) |
1364 | 12 | return $entries=$entries2 | 12 | return count($entries)=count($entries2) |
1365 | 13 | 13 | ||
1366 | 14 | 14 | ||
1367 | === modified file 'test/Queries/dir_04.xq' | |||
1368 | --- test/Queries/dir_04.xq 2012-09-06 20:40:47 +0000 | |||
1369 | +++ test/Queries/dir_04.xq 2013-07-29 19:28:26 +0000 | |||
1370 | @@ -1,13 +1,13 @@ | |||
1372 | 1 | import module namespace a = "http://www.zorba-xquery.com/modules/archive"; | 1 | import module namespace a = "http://zorba.io/modules/archive"; |
1373 | 2 | 2 | ||
1374 | 3 | let $foo-content := "<foo/>" | 3 | let $foo-content := "<foo/>" |
1375 | 4 | let $bar-content := "<bar/>" | 4 | let $bar-content := "<bar/>" |
1376 | 5 | let $archive := a:create( | 5 | let $archive := a:create( |
1378 | 6 | ("foo.xml", "bar.xml", <entry type="directory">dir1</entry>), | 6 | ("foo.xml", "bar.xml", { "type" : "directory", "name" : "dir1" }), |
1379 | 7 | ($foo-content, $bar-content) | 7 | ($foo-content, $bar-content) |
1380 | 8 | ) | 8 | ) |
1382 | 9 | let $archive2 := a:update($archive, <a:entry type="directory">newdir</a:entry>, ()) | 9 | let $archive2 := a:update($archive, { "type" : "directory", "name" : "newdir" }, ()) |
1383 | 10 | let $entries := a:entries($archive) | 10 | let $entries := a:entries($archive) |
1384 | 11 | let $entries2 := a:entries($archive2) | 11 | let $entries2 := a:entries($archive2) |
1386 | 12 | return for $e in $entries2 return concat($e/text(), ",") | 12 | return for $e in $entries2("name") return concat($e, ",") |
1387 | 13 | 13 | ||
1388 | 14 | 14 | ||
1389 | === modified file 'test/Queries/entries_01.xq' | |||
1390 | --- test/Queries/entries_01.xq 2012-07-27 03:43:13 +0000 | |||
1391 | +++ test/Queries/entries_01.xq 2013-07-29 19:28:26 +0000 | |||
1392 | @@ -1,6 +1,7 @@ | |||
1395 | 1 | import module namespace a = "http://www.zorba-xquery.com/modules/archive"; | 1 | import module namespace a = "http://zorba.io/modules/archive"; |
1396 | 2 | import schema namespace as = "http://www.zorba-xquery.com/modules/archive"; | 2 | (: import schema namespace as = "http://zorba.io/modules/archive"; :) |
1397 | 3 | import module namespace f = "http://expath.org/ns/file"; | 3 | import module namespace f = "http://expath.org/ns/file"; |
1398 | 4 | 4 | ||
1399 | 5 | for $a in a:entries(f:read-binary(resolve-uri("simple.zip"))) | 5 | for $a in a:entries(f:read-binary(resolve-uri("simple.zip"))) |
1401 | 6 | return validate { $a } | 6 | (: return validate { $a } :) |
1402 | 7 | return $a | ||
1403 | 7 | 8 | ||
1404 | === modified file 'test/Queries/entries_02.xq' | |||
1405 | --- test/Queries/entries_02.xq 2012-07-27 03:43:13 +0000 | |||
1406 | +++ test/Queries/entries_02.xq 2013-07-29 19:28:26 +0000 | |||
1407 | @@ -1,7 +1,6 @@ | |||
1410 | 1 | import module namespace a = "http://www.zorba-xquery.com/modules/archive"; | 1 | import module namespace a = "http://zorba.io/modules/archive"; |
1409 | 2 | import schema namespace as = "http://www.zorba-xquery.com/modules/archive"; | ||
1411 | 3 | import module namespace f = "http://expath.org/ns/file"; | 2 | import module namespace f = "http://expath.org/ns/file"; |
1412 | 4 | 3 | ||
1413 | 5 | for $a in a:entries(f:read-binary(resolve-uri("simple.tar.gz"))) | 4 | for $a in a:entries(f:read-binary(resolve-uri("simple.tar.gz"))) |
1415 | 6 | return validate { $a } | 5 | return $a |
1416 | 7 | 6 | ||
1417 | 8 | 7 | ||
1418 | === modified file 'test/Queries/entries_03.spec' | |||
1419 | --- test/Queries/entries_03.spec 2012-09-06 20:40:47 +0000 | |||
1420 | +++ test/Queries/entries_03.spec 2013-07-29 19:28:26 +0000 | |||
1421 | @@ -1,1 +1,1 @@ | |||
1423 | 1 | Error: http://www.zorba-xquery.com/modules/archive:ARCH9999 | 1 | Error: http://zorba.io/modules/archive:CORRUPTED-ARCHIVE |
1424 | 2 | 2 | ||
1425 | === modified file 'test/Queries/entries_03.xq' | |||
1426 | --- test/Queries/entries_03.xq 2012-07-27 03:43:13 +0000 | |||
1427 | +++ test/Queries/entries_03.xq 2013-07-29 19:28:26 +0000 | |||
1428 | @@ -1,7 +1,8 @@ | |||
1431 | 1 | import module namespace a = "http://www.zorba-xquery.com/modules/archive"; | 1 | import module namespace a = "http://zorba.io/modules/archive"; |
1432 | 2 | import schema namespace as = "http://www.zorba-xquery.com/modules/archive"; | 2 | (: import schema namespace as = "http://zorba.io/modules/archive"; :) |
1433 | 3 | import module namespace f = "http://expath.org/ns/file"; | 3 | import module namespace f = "http://expath.org/ns/file"; |
1434 | 4 | 4 | ||
1435 | 5 | for $a in a:entries(f:read-binary(resolve-uri("simple.tar.bz2"))) | 5 | for $a in a:entries(f:read-binary(resolve-uri("simple.tar.bz2"))) |
1437 | 6 | return validate { $a } | 6 | (: return validate { $a } :) |
1438 | 7 | return $a | ||
1439 | 7 | 8 | ||
1440 | 8 | 9 | ||
1441 | === modified file 'test/Queries/entries_04.spec' | |||
1442 | --- test/Queries/entries_04.spec 2012-07-27 03:43:13 +0000 | |||
1443 | +++ test/Queries/entries_04.spec 2013-07-29 19:28:26 +0000 | |||
1444 | @@ -1,1 +1,1 @@ | |||
1446 | 1 | Error: http://www.zorba-xquery.com/modules/archive:ARCH9999 | 1 | Error: http://zorba.io/modules/archive:CORRUPTED-ARCHIVE |
1447 | 2 | 2 | ||
1448 | === modified file 'test/Queries/entries_04.xq' | |||
1449 | --- test/Queries/entries_04.xq 2012-07-27 03:43:13 +0000 | |||
1450 | +++ test/Queries/entries_04.xq 2013-07-29 19:28:26 +0000 | |||
1451 | @@ -1,7 +1,8 @@ | |||
1454 | 1 | import module namespace a = "http://www.zorba-xquery.com/modules/archive"; | 1 | import module namespace a = "http://zorba.io/modules/archive"; |
1455 | 2 | import schema namespace as = "http://www.zorba-xquery.com/modules/archive"; | 2 | (: import schema namespace as = "http://zorba.io/modules/archive"; :) |
1456 | 3 | import module namespace f = "http://expath.org/ns/file"; | 3 | import module namespace f = "http://expath.org/ns/file"; |
1457 | 4 | 4 | ||
1458 | 5 | for $a in a:entries(f:read-binary(resolve-uri("invalid.zip"))) | 5 | for $a in a:entries(f:read-binary(resolve-uri("invalid.zip"))) |
1460 | 6 | return validate { $a } | 6 | (: return validate { $a } :) |
1461 | 7 | return $a | ||
1462 | 7 | 8 | ||
1463 | 8 | 9 | ||
1464 | === modified file 'test/Queries/extract_01.xq' | |||
1465 | --- test/Queries/extract_01.xq 2012-07-27 03:43:13 +0000 | |||
1466 | +++ test/Queries/extract_01.xq 2013-07-29 19:28:26 +0000 | |||
1467 | @@ -1,5 +1,4 @@ | |||
1470 | 1 | import module namespace a = "http://www.zorba-xquery.com/modules/archive"; | 1 | import module namespace a = "http://zorba.io/modules/archive"; |
1469 | 2 | import schema namespace as = "http://www.zorba-xquery.com/modules/archive"; | ||
1471 | 3 | import module namespace f = "http://expath.org/ns/file"; | 2 | import module namespace f = "http://expath.org/ns/file"; |
1472 | 4 | 3 | ||
1473 | 5 | for $a in a:extract-text(f:read-binary(resolve-uri("simple.zip"))) | 4 | for $a in a:extract-text(f:read-binary(resolve-uri("simple.zip"))) |
1474 | 6 | 5 | ||
1475 | === modified file 'test/Queries/extract_02.xq' | |||
1476 | --- test/Queries/extract_02.xq 2012-07-27 03:43:13 +0000 | |||
1477 | +++ test/Queries/extract_02.xq 2013-07-29 19:28:26 +0000 | |||
1478 | @@ -1,4 +1,4 @@ | |||
1480 | 1 | import module namespace a = "http://www.zorba-xquery.com/modules/archive"; | 1 | import module namespace a = "http://zorba.io/modules/archive"; |
1481 | 2 | import module namespace f = "http://expath.org/ns/file"; | 2 | import module namespace f = "http://expath.org/ns/file"; |
1482 | 3 | 3 | ||
1483 | 4 | for $a in a:extract-text(f:read-binary(fn:resolve-uri("simple.zip")), "dir1/file1") | 4 | for $a in a:extract-text(f:read-binary(fn:resolve-uri("simple.zip")), "dir1/file1") |
1484 | 5 | 5 | ||
1485 | === modified file 'test/Queries/extract_03.spec' | |||
1486 | --- test/Queries/extract_03.spec 2012-07-27 03:43:13 +0000 | |||
1487 | +++ test/Queries/extract_03.spec 2013-07-29 19:28:26 +0000 | |||
1488 | @@ -1,1 +1,1 @@ | |||
1490 | 1 | Error: http://www.zorba-xquery.com/modules/archive:ARCH0004 | 1 | Error: http://zorba.io/modules/archive:INVALID-ENCODING |
1491 | 2 | 2 | ||
1492 | === modified file 'test/Queries/extract_03.xq' | |||
1493 | --- test/Queries/extract_03.xq 2012-07-27 03:43:13 +0000 | |||
1494 | +++ test/Queries/extract_03.xq 2013-07-29 19:28:26 +0000 | |||
1495 | @@ -1,4 +1,4 @@ | |||
1497 | 1 | import module namespace a = "http://www.zorba-xquery.com/modules/archive"; | 1 | import module namespace a = "http://zorba.io/modules/archive"; |
1498 | 2 | import module namespace f = "http://expath.org/ns/file"; | 2 | import module namespace f = "http://expath.org/ns/file"; |
1499 | 3 | 3 | ||
1500 | 4 | for $a in a:extract-text(f:read-binary(fn:resolve-uri("simple.zip")), "dir1/file1", "foo") | 4 | for $a in a:extract-text(f:read-binary(fn:resolve-uri("simple.zip")), "dir1/file1", "foo") |
1501 | 5 | 5 | ||
1502 | === modified file 'test/Queries/extract_04.xq' | |||
1503 | --- test/Queries/extract_04.xq 2012-07-27 03:43:13 +0000 | |||
1504 | +++ test/Queries/extract_04.xq 2013-07-29 19:28:26 +0000 | |||
1505 | @@ -1,4 +1,4 @@ | |||
1507 | 1 | import module namespace a = "http://www.zorba-xquery.com/modules/archive"; | 1 | import module namespace a = "http://zorba.io/modules/archive"; |
1508 | 2 | import module namespace f = "http://expath.org/ns/file"; | 2 | import module namespace f = "http://expath.org/ns/file"; |
1509 | 3 | 3 | ||
1510 | 4 | for $a in a:extract-text(f:read-binary(fn:resolve-uri("transcoding.zip")), "dir2/iso-8859-1.txt", "ISO-8859-1") | 4 | for $a in a:extract-text(f:read-binary(fn:resolve-uri("transcoding.zip")), "dir2/iso-8859-1.txt", "ISO-8859-1") |
1511 | 5 | 5 | ||
1512 | === modified file 'test/Queries/extract_05.xq' | |||
1513 | --- test/Queries/extract_05.xq 2012-07-27 03:43:13 +0000 | |||
1514 | +++ test/Queries/extract_05.xq 2013-07-29 19:28:26 +0000 | |||
1515 | @@ -1,7 +1,7 @@ | |||
1517 | 1 | import module namespace a = "http://www.zorba-xquery.com/modules/archive"; | 1 | import module namespace a = "http://zorba.io/modules/archive"; |
1518 | 2 | import module namespace f = "http://expath.org/ns/file"; | 2 | import module namespace f = "http://expath.org/ns/file"; |
1519 | 3 | 3 | ||
1520 | 4 | let $f := f:read-binary(resolve-uri("linear-algebra-20120306.epub")) | 4 | let $f := f:read-binary(resolve-uri("linear-algebra-20120306.epub")) |
1524 | 5 | for $a in a:entries($f) | 5 | for $a in a:entries($f)("name") |
1525 | 6 | where $a/text() eq "EPUB/xhtml/fcla-xml-2.30li91.html" | 6 | where $a eq "EPUB/xhtml/fcla-xml-2.30li91.html" |
1526 | 7 | return a:extract-text($f, $a/text()) | 7 | return a:extract-text($f, $a) |
1527 | 8 | 8 | ||
1528 | === modified file 'test/Queries/extract_06.xq' | |||
1529 | --- test/Queries/extract_06.xq 2012-07-27 03:43:13 +0000 | |||
1530 | +++ test/Queries/extract_06.xq 2013-07-29 19:28:26 +0000 | |||
1531 | @@ -1,4 +1,4 @@ | |||
1533 | 1 | import module namespace a = "http://www.zorba-xquery.com/modules/archive"; | 1 | import module namespace a = "http://zorba.io/modules/archive"; |
1534 | 2 | import module namespace f = "http://expath.org/ns/file"; | 2 | import module namespace f = "http://expath.org/ns/file"; |
1535 | 3 | 3 | ||
1536 | 4 | for $a in a:extract-binary(f:read-binary(fn:resolve-uri("simple.zip")), "dir1/file1") | 4 | for $a in a:extract-binary(f:read-binary(fn:resolve-uri("simple.zip")), "dir1/file1") |
1537 | 5 | 5 | ||
1538 | === modified file 'test/Queries/extract_07.xq' | |||
1539 | --- test/Queries/extract_07.xq 2012-07-27 03:43:13 +0000 | |||
1540 | +++ test/Queries/extract_07.xq 2013-07-29 19:28:26 +0000 | |||
1541 | @@ -1,6 +1,6 @@ | |||
1543 | 1 | import module namespace a = "http://www.zorba-xquery.com/modules/archive"; | 1 | import module namespace a = "http://zorba.io/modules/archive"; |
1544 | 2 | import module namespace f = "http://expath.org/ns/file"; | 2 | import module namespace f = "http://expath.org/ns/file"; |
1545 | 3 | 3 | ||
1546 | 4 | let $f := f:read-binary(fn:resolve-uri("linear-algebra-20120306.epub")) | 4 | let $f := f:read-binary(fn:resolve-uri("linear-algebra-20120306.epub")) |
1548 | 5 | for $a in a:entries($f)[position() > 2 and position() < 5] | 5 | for $a in a:entries($f)("name")[position() > 2 and position() < 5] |
1549 | 6 | return <text>{a:extract-binary($f, $a)}</text> | 6 | return <text>{a:extract-binary($f, $a)}</text> |
1550 | 7 | 7 | ||
1551 | === modified file 'test/Queries/options_01.xq' | |||
1552 | --- test/Queries/options_01.xq 2012-08-03 21:54:38 +0000 | |||
1553 | +++ test/Queries/options_01.xq 2013-07-29 19:28:26 +0000 | |||
1554 | @@ -1,4 +1,4 @@ | |||
1556 | 1 | import module namespace a = "http://www.zorba-xquery.com/modules/archive"; | 1 | import module namespace a = "http://zorba.io/modules/archive"; |
1557 | 2 | import module namespace f = "http://expath.org/ns/file"; | 2 | import module namespace f = "http://expath.org/ns/file"; |
1558 | 3 | 3 | ||
1559 | 4 | let $zip := f:read-binary(fn:resolve-uri("linear-algebra-20120306.epub")) | 4 | let $zip := f:read-binary(fn:resolve-uri("linear-algebra-20120306.epub")) |
1560 | 5 | 5 | ||
1561 | === modified file 'test/Queries/options_02.spec' | |||
1562 | --- test/Queries/options_02.spec 2012-09-06 20:40:47 +0000 | |||
1563 | +++ test/Queries/options_02.spec 2013-07-29 19:28:26 +0000 | |||
1564 | @@ -1,1 +1,1 @@ | |||
1566 | 1 | Error: http://www.zorba-xquery.com/modules/archive:ARCH9999 | 1 | Error: http://zorba.io/modules/archive:CORRUPTED-ARCHIVE |
1567 | 2 | 2 | ||
1568 | === modified file 'test/Queries/options_02.xq' | |||
1569 | --- test/Queries/options_02.xq 2012-09-06 20:40:47 +0000 | |||
1570 | +++ test/Queries/options_02.xq 2013-07-29 19:28:26 +0000 | |||
1571 | @@ -1,4 +1,4 @@ | |||
1573 | 1 | import module namespace a = "http://www.zorba-xquery.com/modules/archive"; | 1 | import module namespace a = "http://zorba.io/modules/archive"; |
1574 | 2 | import module namespace f = "http://expath.org/ns/file"; | 2 | import module namespace f = "http://expath.org/ns/file"; |
1575 | 3 | 3 | ||
1576 | 4 | let $tar-bz2 := f:read-binary(fn:resolve-uri("simple.tar.bz2")) | 4 | let $tar-bz2 := f:read-binary(fn:resolve-uri("simple.tar.bz2")) |
1577 | 5 | 5 | ||
1578 | === modified file 'test/Queries/options_03.spec' | |||
1579 | --- test/Queries/options_03.spec 2012-09-06 20:40:47 +0000 | |||
1580 | +++ test/Queries/options_03.spec 2013-07-29 19:28:26 +0000 | |||
1581 | @@ -1,1 +1,1 @@ | |||
1583 | 1 | Error: http://www.zorba-xquery.com/modules/archive:ARCH9999 | 1 | Error: http://zorba.io/modules/archive:CORRUPTED-ARCHIVE |
1584 | 2 | 2 | ||
1585 | === modified file 'test/Queries/options_03.xq' | |||
1586 | --- test/Queries/options_03.xq 2012-09-06 20:40:47 +0000 | |||
1587 | +++ test/Queries/options_03.xq 2013-07-29 19:28:26 +0000 | |||
1588 | @@ -1,4 +1,4 @@ | |||
1590 | 1 | import module namespace a = "http://www.zorba-xquery.com/modules/archive"; | 1 | import module namespace a = "http://zorba.io/modules/archive"; |
1591 | 2 | 2 | ||
1592 | 3 | let $fake_archive := xs:base64Binary("5Pb8") | 3 | let $fake_archive := xs:base64Binary("5Pb8") |
1593 | 4 | return | 4 | return |
1594 | 5 | 5 | ||
1595 | === modified file 'test/Queries/update_01.xq' | |||
1596 | --- test/Queries/update_01.xq 2013-07-17 07:50:04 +0000 | |||
1597 | +++ test/Queries/update_01.xq 2013-07-29 19:28:26 +0000 | |||
1598 | @@ -1,4 +1,4 @@ | |||
1600 | 1 | import module namespace a = "http://www.zorba-xquery.com/modules/archive"; | 1 | import module namespace a = "http://zorba.io/modules/archive"; |
1601 | 2 | import module namespace b = "http://zorba.io/modules/base64"; | 2 | import module namespace b = "http://zorba.io/modules/base64"; |
1602 | 3 | 3 | ||
1603 | 4 | let $foo-content := "<foo/>" | 4 | let $foo-content := "<foo/>" |
1604 | 5 | 5 | ||
1605 | === modified file 'test/Queries/update_02.xq' | |||
1606 | --- test/Queries/update_02.xq 2013-07-17 07:50:04 +0000 | |||
1607 | +++ test/Queries/update_02.xq 2013-07-29 19:28:26 +0000 | |||
1608 | @@ -1,4 +1,4 @@ | |||
1610 | 1 | import module namespace a = "http://www.zorba-xquery.com/modules/archive"; | 1 | import module namespace a = "http://zorba.io/modules/archive"; |
1611 | 2 | import module namespace b = "http://zorba.io/modules/base64"; | 2 | import module namespace b = "http://zorba.io/modules/base64"; |
1612 | 3 | 3 | ||
1613 | 4 | let $foo-content := "<foo/>" | 4 | let $foo-content := "<foo/>" |
1614 | 5 | 5 | ||
1615 | === modified file 'test/Queries/update_03.spec' | |||
1616 | --- test/Queries/update_03.spec 2012-09-06 20:40:47 +0000 | |||
1617 | +++ test/Queries/update_03.spec 2013-07-29 19:28:26 +0000 | |||
1618 | @@ -1,1 +1,1 @@ | |||
1620 | 1 | Error: http://www.zorba-xquery.com/modules/archive:ARCH0001 | 1 | Error: http://zorba.io/modules/archive:ENTRY-COUNT |
1621 | 2 | 2 | ||
1622 | === modified file 'test/Queries/update_03.xq' | |||
1623 | --- test/Queries/update_03.xq 2013-07-17 07:50:04 +0000 | |||
1624 | +++ test/Queries/update_03.xq 2013-07-29 19:28:26 +0000 | |||
1625 | @@ -1,4 +1,4 @@ | |||
1627 | 1 | import module namespace a = "http://www.zorba-xquery.com/modules/archive"; | 1 | import module namespace a = "http://zorba.io/modules/archive"; |
1628 | 2 | import module namespace b = "http://zorba.io/modules/base64"; | 2 | import module namespace b = "http://zorba.io/modules/base64"; |
1629 | 3 | 3 | ||
1630 | 4 | let $foo-content := "<foo/>" | 4 | let $foo-content := "<foo/>" |
1631 | 5 | 5 | ||
1632 | === modified file 'test/Queries/update_04.spec' | |||
1633 | --- test/Queries/update_04.spec 2012-09-06 20:40:47 +0000 | |||
1634 | +++ test/Queries/update_04.spec 2013-07-29 19:28:26 +0000 | |||
1635 | @@ -1,1 +1,1 @@ | |||
1637 | 1 | Error: http://www.zorba-xquery.com/modules/archive:ARCH9999 | 1 | Error: http://zorba.io/modules/archive:CORRUPTED-ARCHIVE |
1638 | 2 | 2 | ||
1639 | === modified file 'test/Queries/update_04.xq' | |||
1640 | --- test/Queries/update_04.xq 2013-07-17 07:50:04 +0000 | |||
1641 | +++ test/Queries/update_04.xq 2013-07-29 19:28:26 +0000 | |||
1642 | @@ -1,4 +1,4 @@ | |||
1644 | 1 | import module namespace a = "http://www.zorba-xquery.com/modules/archive"; | 1 | import module namespace a = "http://zorba.io/modules/archive"; |
1645 | 2 | import module namespace b = "http://zorba.io/modules/base64"; | 2 | import module namespace b = "http://zorba.io/modules/base64"; |
1646 | 3 | 3 | ||
1647 | 4 | let $fake_archive := xs:base64Binary("YWJj") | 4 | let $fake_archive := xs:base64Binary("YWJj") |
In archive_module.cpp:
1. Please don't leave commented-out code. Just delete it; it's in the version history if we ever need to refer back to it. For example, remove these lines:
+ //Item lNameItem = theFactory- >createString( lName); >createString( "name") ;
+ //lMemberName = theFactory-
2. As discussed, if possible, create single zorba::Items for all the JSON object key strings, eg. "name", "size", etc. Possibly create those in the ArchiveModule constructor. Use those constants when creating JSON objects in EntriesIterator ::next( ), as well as comparing input values in ArchiveEntry: :setValues( ) (and anywhere else it happens to be appropriate).
Also don't forget to assign a bug to yourself to create a JSON schema for this module, and to go back and update the module and test cases accordingly.