Merge lp:~zorba-coders/zorba/1039576 into lp:zorba/archive-module

Proposed by Luis Rodriguez Gonzalez
Status: Merged
Approved by: Matthias Brantner
Approved revision: 52
Merged at revision: 45
Proposed branch: lp:~zorba-coders/zorba/1039576
Merge into: lp:zorba/archive-module
Diff against target: 771 lines (+289/-119)
28 files modified
src/archive.xsd (+8/-0)
src/archive_module.xq (+26/-10)
src/archive_module.xq.src/archive_module.cpp (+131/-106)
src/archive_module.xq.src/archive_module.h (+15/-0)
test/ExpQueryResults/dir_01.xml.res (+2/-0)
test/ExpQueryResults/dir_02.xml.res (+2/-0)
test/ExpQueryResults/dir_03.xml.res (+2/-0)
test/ExpQueryResults/dir_04.xml.res (+2/-0)
test/ExpQueryResults/entries_01.xml.res (+1/-1)
test/ExpQueryResults/entries_02.xml.res (+1/-1)
test/ExpQueryResults/entries_03.xml.res (+1/-1)
test/ExpQueryResults/options_02.xml.res (+2/-0)
test/ExpQueryResults/update_02.xml.res (+2/-0)
test/ExpQueryResults/update_03.xml.res (+1/-0)
test/Queries/dir_01.xq (+10/-0)
test/Queries/dir_02.xq (+11/-0)
test/Queries/dir_03.xq (+13/-0)
test/Queries/dir_04.xq (+13/-0)
test/Queries/entries_03.spec (+1/-0)
test/Queries/options_02.spec (+1/-0)
test/Queries/options_02.xq (+5/-0)
test/Queries/options_03.spec (+1/-0)
test/Queries/options_03.xq (+5/-0)
test/Queries/update_02.xq (+12/-0)
test/Queries/update_03.spec (+1/-0)
test/Queries/update_03.xq (+12/-0)
test/Queries/update_04.spec (+1/-0)
test/Queries/update_04.xq (+7/-0)
To merge this branch: bzr merge lp:~zorba-coders/zorba/1039576
Reviewer Review Type Date Requested Status
Matthias Brantner Approve
Juan Zacarias Approve
Review via email: mp+123170@code.launchpad.net

Commit message

- Added ability to create directories in archives
- Added testcases

Description of the change

- Added ability to create directories in archives
- Added testcases

To post a comment you must log in.
Revision history for this message
Juan Zacarias (juan457) :
review: Approve
Revision history for this message
Matthias Brantner (matthias-brantner) wrote :

The following tests started to fail on my Linux machine. Any clue why?

 3613 - zorba_archive_module/entries_03.xq (Failed)
 3618 - zorba_archive_module/dir_04.xq (Failed)
 3619 - zorba_archive_module/dir_02.xq (Failed)
 3625 - zorba_archive_module/update_02.xq (Failed)
 3629 - zorba_archive_module/entries_02.xq (Failed)
 3633 - zorba_archive_module/dir_01.xq (Failed)
 3635 - zorba_archive_module/entries_01.xq (Failed)
 3636 - zorba_archive_module/dir_03.xq (Failed)
 3638 - zorba_archive_module/options_02.xq (Failed)

review: Needs Fixing
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.

lp:~zorba-coders/zorba/1039576 updated
52. By luisrod <luisrod@LUISROD-LAP>

- Added entry@type attribute to documentation

Revision history for this message
Luis Rodriguez Gonzalez (kuraru) wrote :

- Added documentation changes to include entry@type attribute.

Revision history for this message
Matthias Brantner (matthias-brantner) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job 1039576-2013-01-08T05-24-49.124Z is finished. The final status was:

All tests succeeded!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/archive.xsd'
2--- src/archive.xsd 2012-08-01 20:47:46 +0000
3+++ src/archive.xsd 2012-12-21 22:13:22 +0000
4@@ -53,6 +53,13 @@
5 <xs:restriction base="xs:string"/>
6 </xs:simpleType>
7
8+ <xs:simpleType name="entry-type">
9+ <xs:restriction base="xs:string">
10+ <xs:enumeration value="regular"/>
11+ <xs:enumeration value="directory"/>
12+ </xs:restriction>
13+ </xs:simpleType>
14+
15 <!-- elements -->
16 <xs:element name="archive-option-element"
17 abstract="true" type="xs:string"/>
18@@ -88,6 +95,7 @@
19
20 <!-- entry attributes -->
21 <xs:attributeGroup name="entry-attributes">
22+ <xs:attribute name="type" type="entry-type"/>
23 <xs:attribute name="size" type="entry-size-type"/>
24 <xs:attribute name="last-modified" type="entry-datetime-type"/>
25 <xs:attribute name="encoding" type="entry-encoding-type"/>
26
27=== modified file 'src/archive_module.xq'
28--- src/archive_module.xq 2012-09-28 13:58:19 +0000
29+++ src/archive_module.xq 2012-12-21 22:13:22 +0000
30@@ -49,6 +49,19 @@
31 : <p>The parameters $entries and $contents have the same meaning as for
32 : the function a:create with three arguments.</p>
33 :
34+ : <p>Entry entries can include a type attribute, this attribute can have one
35+ : of two possible values: "regular" or "directory". If "regular" is
36+ : specified then the entry will be created as a regular file; if "directory"
37+ : is specified then the entry will be created as a directory, no contents
38+ : will be read from $contents in this case. If no value is specified for type
39+ : then it will be set to "regular". Example:
40+ : <pre>
41+ : $zip-file := a:create(
42+ : (&lt;a:entry encoding="ISO-8859-1" type="directory">dir1&lt;/a:entry>, "dir1/file1"),
43+ : ("file contents"))
44+ : </pre>
45+ : </p>
46+ :
47 : @param $entries the meta data for the entries in the archive. Each entry
48 : can be of type xs:string or an element with name a:entry.
49 : @param $contents the content for the archive. Each item in the sequence
50@@ -90,18 +103,20 @@
51 :
52 : <p>For example, the following sequence may be used to describe an archive
53 : containing three elements:
54- : <pre class="ace-static" ace-mode="xquery"><![CDATA[<a:entry last-modified="{fn:current-dateTime()}">myfile.txt</a:entry>
55- : <a:entry encoding="ISO-8859-1" compression="store">dir/myfile.xml</a:entry>]]></pre>
56+ : <pre class="ace-static" ace-mode="xquery"><![CDATA[&lt;a:entry last-modified="{fn:current-dateTime()}">myfile.txt&lt;/a:entry>
57+ : &lt;a:entry encoding="ISO-8859-1" compression="store">dir/myfile.xml&lt;/a:entry>]]>
58+ : </pre>
59 : </p>
60 :
61 : <p>The $options argument may be used to describe general options for the
62 : archive. For example, the following option element can be used to create a ZIP
63 : archive in which all entries are compressed with the DEFLATE compression
64 : algorithm:
65- : <pre class="ace-static" ace-mode="xquery"><![CDATA[<archive:options>
66- : <archive:format>ZIP</archive:format>
67- : <archive:compression>DEFLATE</archive:compression>
68- : </archive:options>]]></pre>
69+ : <pre class="ace-static" ace-mode="xquery"><![CDATA[&lt;archive:options>
70+ : &lt;archive:format>ZIP&lt;/archive:format>
71+ : &lt;archive:compression>DEFLATE&lt;/archive:compression>
72+ : &lt;/archive:options>]]>
73+ : </pre>
74 : </p>
75 :
76 : <p>The result of the function is the generated archive as a item of type
77@@ -271,10 +286,11 @@
78 : Returns the algorithm and format options of the given archive.
79 : For example, for a ZIP archive, the following options element
80 : would be returned:
81- : <pre class="ace-static" ace-mode="xquery"><![CDATA[<archive:options>
82- : <archive:format>ZIP&lt;/archive:format>
83- : <archive:compressionDEFLATE&lt;/archive:compression>
84- : </archive:options>]]></pre>
85+ : <pre class="ace-static" ace-mode="xquery"><![CDATA[&lt;archive:options>
86+ : &lt;archive:format>ZIP&lt;/archive:format>
87+ : &lt;archive:compressionDEFLATE&lt;/archive:compression>
88+ : &lt;/archive:options>]]>
89+ : </pre>
90 :
91 : @param $archive the archive as xs:base64Binary
92 :
93
94=== modified file 'src/archive_module.xq.src/archive_module.cpp'
95--- src/archive_module.xq.src/archive_module.cpp 2012-08-03 04:53:47 +0000
96+++ src/archive_module.xq.src/archive_module.cpp 2012-12-21 22:13:22 +0000
97@@ -119,6 +119,8 @@
98 gmtime_r(&aTime, &gmtm);
99 #endif
100
101+ // create a datetime item without timezone because
102+ // this is what the entry tells us (at least for zip)
103 Item lModifiedItem = getItemFactory()->createDateTime(
104 static_cast<short>(gmtm.tm_year + 1900),
105 static_cast<short>(gmtm.tm_mon + 1),
106@@ -167,7 +169,8 @@
107 ******************/
108
109 ArchiveFunction::ArchiveEntry::ArchiveEntry()
110- : theEncoding("UTF-8")
111+ : theEncoding("UTF-8"),
112+ theEntryType(regular)
113 {
114 // use current time as a default for each entry
115 #if defined (WIN32)
116@@ -187,7 +190,7 @@
117
118 if (archive_entry_size_is_set(aEntry))
119 {
120- //add a size variable
121+ theSize = (int)archive_entry_size(aEntry);
122 }
123
124 if (archive_entry_mtime_is_set(aEntry))
125@@ -195,12 +198,19 @@
126 theLastModified = archive_entry_mtime(aEntry);
127 }
128 //check if it is encoded
129+
130+ switch(archive_entry_filetype(aEntry))
131+ {
132+ case AE_IFDIR: theEntryType = directory; break;
133+ default: theEntryType = regular; break;
134+ }
135 }
136
137 void
138 ArchiveFunction::ArchiveEntry::setValues(zorba::Item& aEntry)
139 {
140 theEntryPath = aEntry.getStringValue();
141+
142 if (aEntry.isNode())
143 {
144 Item lAttr;
145@@ -212,7 +222,15 @@
146 Item lAttrName;
147 lAttr.getNodeName(lAttrName);
148
149- if (lAttrName.getLocalName() == "last-modified")
150+ if(lAttrName.getLocalName() == "type")
151+ {
152+ String filetype = lAttr.getStringValue();
153+ if(filetype == "directory")
154+ {
155+ theEntryType = directory;
156+ }
157+ }
158+ else if (lAttrName.getLocalName() == "last-modified")
159 {
160 ArchiveModule::parseDateTimeItem(lAttr, theLastModified);
161 }
162@@ -548,12 +566,15 @@
163
164 for (size_t i = 0; i < aEntries.size(); ++i)
165 {
166- if (!aFiles->next(lFile))
167+ if(aEntries[i].getEntryType() == ArchiveEntry::regular)
168 {
169- std::ostringstream lMsg;
170- lMsg << "number of entries (" << aEntries.size()
171- << ") doesn't match number of content arguments (" << i << ")";
172- throwError("ARCH0001", lMsg.str().c_str());
173+ if (!aFiles->next(lFile))
174+ {
175+ std::ostringstream lMsg;
176+ lMsg << "number of entries (" << aEntries.size()
177+ << ") doesn't match number of content arguments (" << i << ")";
178+ throwError("ARCH0001", lMsg.str().c_str());
179+ }
180 }
181
182 const ArchiveEntry& lEntry = aEntries[i];
183@@ -578,14 +599,19 @@
184 std::istream* lStream;
185 bool lDeleteStream;
186 uint64_t lFileSize;
187-
188- lDeleteStream = getStream(
189- aEntry, aFile, lStream, lFileSize);
190
191 archive_entry_set_pathname(theEntry, aEntry.getEntryPath().c_str());
192 archive_entry_set_mtime(theEntry, aEntry.getLastModified(), 0);
193 // TODO: modified to allow the creation of empty directories
194- archive_entry_set_filetype(theEntry, AE_IFREG);
195+ if(aEntry.getEntryType() == ArchiveEntry::regular){
196+ archive_entry_set_filetype(theEntry, AE_IFREG);
197+ lDeleteStream = getStream(
198+ aEntry, aFile, lStream, lFileSize);
199+ } else {
200+ archive_entry_set_filetype(theEntry, AE_IFDIR);
201+ lDeleteStream = false;
202+ lFileSize = 0;
203+ }
204 // TODO: specifies the permits of a file
205 archive_entry_set_perm(theEntry, 0644);
206 archive_entry_set_size(theEntry, lFileSize);
207@@ -632,11 +658,14 @@
208
209 archive_write_header(theArchive, theEntry);
210
211- char lBuf[ZORBA_ARCHIVE_MAX_READ_BUF];
212- while (lStream->good())
213+ if(aEntry.getEntryType() == ArchiveEntry::regular)
214 {
215- lStream->read(lBuf, ZORBA_ARCHIVE_MAX_READ_BUF);
216- archive_write_data(theArchive, lBuf, lStream->gcount());
217+ char lBuf[ZORBA_ARCHIVE_MAX_READ_BUF];
218+ while (lStream->good())
219+ {
220+ lStream->read(lBuf, ZORBA_ARCHIVE_MAX_READ_BUF);
221+ archive_write_data(theArchive, lBuf, lStream->gcount());
222+ }
223 }
224
225 archive_entry_clear(theEntry);
226@@ -890,9 +919,15 @@
227 base64::attach(*theData.theStream);
228 }
229
230- lErr = archive_read_open(
231- theArchive, &theData, 0, ArchiveItemSequence::readStream, 0);
232-
233+ lErr = archive_read_set_read_callback(
234+ theArchive, ArchiveItemSequence::readStream);
235+ ArchiveFunction::checkForError(lErr, 0, theArchive);
236+
237+ lErr = archive_read_set_callback_data(
238+ theArchive, &theData);
239+ ArchiveFunction::checkForError(lErr, 0, theArchive);
240+
241+ lErr = archive_read_open1(theArchive);
242 ArchiveFunction::checkForError(lErr, 0, theArchive);
243 }
244 else
245@@ -1021,6 +1056,7 @@
246
247 theLastModifiedName = theFactory->createQName("", "last-modified");
248 theUncompressedSizeName = theFactory->createQName("", "size");
249+ theEntryType = theFactory->createQName("", "type");
250 }
251
252 bool
253@@ -1071,6 +1107,26 @@
254 aRes, theLastModifiedName, lType, lModifiedItem);
255 }
256
257+ Item lEntryType;
258+ if(archive_entry_filetype(lEntry) == AE_IFDIR)
259+ {
260+ // this entry is a directory
261+ lEntryType = theFactory->createString("directory");
262+ }
263+ else if(archive_entry_filetype(lEntry) == AE_IFREG)
264+ {
265+ lEntryType = theFactory->createString("regular");
266+ }
267+ else
268+ {
269+ // error! type not supported!
270+ // for the time being don't do anything
271+ }
272+
273+ lType = theUntypedQName;
274+ theFactory->createAttributeNode(
275+ aRes, theEntryType, lType, lEntryType);
276+
277 // skip to the next entry and raise an error if that fails
278 lErr = archive_read_data_skip(theArchive);
279 ArchiveFunction::checkForError(lErr, 0, theArchive);
280@@ -1183,26 +1239,6 @@
281 if (!lEntry)
282 return false;
283
284- /*while (true)
285- {
286- int lErr = archive_read_next_header(theArchive, &lEntry);
287-
288- if (lErr == ARCHIVE_EOF) return false;
289-
290- if (lErr != ARCHIVE_OK)
291- {
292- ArchiveFunction::checkForError(lErr, 0, theArchive);
293- }
294-
295- if (theReturnAll) break;
296-
297- String lName = archive_entry_pathname(lEntry);
298- if (theEntryNames.find(lName) != theEntryNames.end())
299- {
300- break;
301- }
302- }*/
303-
304 String lResult;
305
306 // reserve some space if we know the decompressed size
307@@ -1294,26 +1330,6 @@
308 if (!lEntry)
309 return false;
310
311- /*while (true)
312- {
313- int lErr = archive_read_next_header(theArchive, &lEntry);
314-
315- if (lErr == ARCHIVE_EOF) return false;
316-
317- if (lErr != ARCHIVE_OK)
318- {
319- ArchiveFunction::checkForError(lErr, 0, theArchive);
320- }
321-
322- if (theReturnAll) break;
323-
324- String lName = archive_entry_pathname(lEntry);
325- if (theEntryNames.find(lName) != theEntryNames.end())
326- {
327- break;
328- }
329- }*/
330-
331 std::vector<unsigned char> lResult;
332
333 // reserve some space if we know the decompressed size
334@@ -1429,32 +1445,34 @@
335
336 //form an ArchiveEntry with the entry
337 theEntry.setValues(lEntry);
338-
339- //read entry content
340- std::vector<unsigned char> lResult;
341-
342- if (archive_entry_size_is_set(lEntry))
343- {
344- long long lSize = archive_entry_size(lEntry);
345- lResult.reserve(lSize);
346- }
347-
348- std::vector<unsigned char> lBuf;
349- lBuf.resize(ZORBA_ARCHIVE_MAX_READ_BUF);
350-
351- //read entry into string
352- while (true)
353- {
354- int s = archive_read_data(
355- theArchive, &lBuf[0], ZORBA_ARCHIVE_MAX_READ_BUF);
356+
357+ if(archive_entry_filetype(lEntry) == AE_IFREG){
358+ //read entry content
359+ std::vector<unsigned char> lResult;
360+
361+ if (archive_entry_size_is_set(lEntry))
362+ {
363+ long long lSize = archive_entry_size(lEntry);
364+ lResult.reserve(lSize);
365+ }
366+
367+ std::vector<unsigned char> lBuf;
368+ lBuf.resize(ZORBA_ARCHIVE_MAX_READ_BUF);
369+
370+ //read entry into string
371+ while (true)
372+ {
373+ int s = archive_read_data(
374+ theArchive, &lBuf[0], ZORBA_ARCHIVE_MAX_READ_BUF);
375
376- if (s == 0) break;
377-
378- lResult.insert(lResult.end(), lBuf.begin(), lBuf.begin() + s);
379+ if (s == 0) break;
380+
381+ lResult.insert(lResult.end(), lBuf.begin(), lBuf.begin() + s);
382+ }
383+
384+ aRes = theFactory->createBase64Binary(&lResult[0], lResult.size());
385 }
386
387- aRes = theFactory->createBase64Binary(&lResult[0], lResult.size());
388-
389 return true;
390 }
391
392@@ -1497,6 +1515,7 @@
393 //updated with the new Files specified
394 ArchiveCompressor lResArchive;
395 ArchiveOptions lOptions;
396+ bool lHasItem = false;
397
398 Item lItem;
399 Iterator_t lSeqIter = lSeq->getIterator();
400@@ -1504,12 +1523,13 @@
401 //read first header and file of the archive so we can get the options before creating
402 //the new archive.
403 lSeqIter->open();
404- lSeqIter->next(lItem);
405+ lHasItem = lSeqIter->next(lItem);
406 //set the options of the archive
407 lOptions = lSeq->getOptions();
408 //create new archive with the options read
409 lResArchive.open(lOptions);
410- if (!lItem.isNull())
411+ //if (!lItem.isNull())
412+ if (lHasItem)
413 {
414 do
415 {
416@@ -1608,31 +1628,36 @@
417
418 //form an ArchiveEntry with the entry
419 theEntry.setValues(lEntry);
420+
421+ if(archive_entry_filetype(lEntry) == AE_IFREG){
422
423- //read entry content
424- std::vector<unsigned char> lResult;
425-
426- if (archive_entry_size_is_set(lEntry))
427- {
428- long long lSize = archive_entry_size(lEntry);
429- lResult.reserve(lSize);
430- }
431-
432- std::vector<unsigned char> lBuf;
433- lBuf.resize(ZORBA_ARCHIVE_MAX_READ_BUF);
434-
435- //read entry into string
436- while (true)
437- {
438- int s = archive_read_data(
439- theArchive, &lBuf[0], ZORBA_ARCHIVE_MAX_READ_BUF);
440+ //read entry content
441+ std::vector<unsigned char> lResult;
442+
443+ if (archive_entry_size_is_set(lEntry))
444+ {
445+ long long lSize = archive_entry_size(lEntry);
446+ lResult.reserve(lSize);
447+ }
448+
449+ std::vector<unsigned char> lBuf;
450+ lBuf.resize(ZORBA_ARCHIVE_MAX_READ_BUF);
451+
452+ //read entry into string
453+ while (true)
454+ {
455+ int s = archive_read_data(
456+ theArchive, &lBuf[0], ZORBA_ARCHIVE_MAX_READ_BUF);
457
458- if (s == 0) break;
459-
460- lResult.insert(lResult.end(), lBuf.begin(), lBuf.begin() + s);
461+ if (s == 0) break;
462+
463+ lResult.insert(lResult.end(), lBuf.begin(), lBuf.begin() + s);
464+ }
465+
466+ aRes = theFactory->createBase64Binary(&lResult[0], lResult.size());
467 }
468-
469- aRes = theFactory->createBase64Binary(&lResult[0], lResult.size());
470+ // else? if the entry represents a directory what are we
471+ // going to return??
472
473 return true;
474 }
475
476=== modified file 'src/archive_module.xq.src/archive_module.h'
477--- src/archive_module.xq.src/archive_module.h 2012-08-01 20:47:46 +0000
478+++ src/archive_module.xq.src/archive_module.h 2012-12-21 22:13:22 +0000
479@@ -150,6 +150,14 @@
480 #endif
481 readStream(struct archive *a, void *client_data, const void **buff);
482
483+ // needed for the "non-linear" zip format
484+#ifdef WIN32
485+ static __int64 seekStream(struct archive *a, void *data, __int64 request, int whence);
486+#else
487+ static off_t seekStream(struct archive *a, void *data, off_t request, int whence);
488+#endif
489+
490+
491 };
492
493
494@@ -196,12 +204,16 @@
495
496 class ArchiveEntry
497 {
498+ public:
499+ enum ArchiveEntryType { regular = 0, directory };
500+
501 protected:
502 String theEntryPath;
503 String theEncoding;
504 int theSize;
505 time_t theLastModified;
506 String theCompression;
507+ ArchiveEntryType theEntryType;
508 bool theSkipExtras;
509
510 public:
511@@ -217,6 +229,8 @@
512
513 const String& getCompression() const { return theCompression; }
514
515+ const ArchiveEntryType& getEntryType() const { return theEntryType; }
516+
517 void setValues(zorba::Item& aEntry);
518
519 void setValues(struct archive_entry* aEntry);
520@@ -362,6 +376,7 @@
521 zorba::Item theEntryName;
522 zorba::Item theUncompressedSizeName;
523 zorba::Item theLastModifiedName;
524+ zorba::Item theEntryType;
525
526 public:
527 EntriesIterator(zorba::Item& aArchive);
528
529=== added file 'test/ExpQueryResults/dir_01.xml.res'
530--- test/ExpQueryResults/dir_01.xml.res 1970-01-01 00:00:00 +0000
531+++ test/ExpQueryResults/dir_01.xml.res 2012-12-21 22:13:22 +0000
532@@ -0,0 +1,2 @@
533+<?xml version="1.0" encoding="UTF-8"?>
534+foo.xml, bar.xml, dir1/,
535\ No newline at end of file
536
537=== added file 'test/ExpQueryResults/dir_02.xml.res'
538--- test/ExpQueryResults/dir_02.xml.res 1970-01-01 00:00:00 +0000
539+++ test/ExpQueryResults/dir_02.xml.res 2012-12-21 22:13:22 +0000
540@@ -0,0 +1,2 @@
541+<?xml version="1.0" encoding="UTF-8"?>
542+foo.xml, bar.xml,
543\ No newline at end of file
544
545=== added file 'test/ExpQueryResults/dir_03.xml.res'
546--- test/ExpQueryResults/dir_03.xml.res 1970-01-01 00:00:00 +0000
547+++ test/ExpQueryResults/dir_03.xml.res 2012-12-21 22:13:22 +0000
548@@ -0,0 +1,2 @@
549+<?xml version="1.0" encoding="UTF-8"?>
550+true
551\ No newline at end of file
552
553=== added file 'test/ExpQueryResults/dir_04.xml.res'
554--- test/ExpQueryResults/dir_04.xml.res 1970-01-01 00:00:00 +0000
555+++ test/ExpQueryResults/dir_04.xml.res 2012-12-21 22:13:22 +0000
556@@ -0,0 +1,2 @@
557+<?xml version="1.0" encoding="UTF-8"?>
558+foo.xml, bar.xml, dir1/, newdir/,
559\ No newline at end of file
560
561=== modified file 'test/ExpQueryResults/entries_01.xml.res'
562--- test/ExpQueryResults/entries_01.xml.res 2012-08-03 21:54:38 +0000
563+++ test/ExpQueryResults/entries_01.xml.res 2012-12-21 22:13:22 +0000
564@@ -1,2 +1,2 @@
565 <?xml version="1.0" encoding="UTF-8"?>
566-<entry xmlns="http://www.zorba-xquery.com/modules/archive" size="0" last-modified="2012-06-15T20:11:09Z">dir1/</entry><entry xmlns="http://www.zorba-xquery.com/modules/archive" size="11" last-modified="2012-06-15T20:11:09Z">dir1/file1</entry><entry xmlns="http://www.zorba-xquery.com/modules/archive" size="11" last-modified="2012-06-15T20:11:03Z">dir1/file2</entry><entry xmlns="http://www.zorba-xquery.com/modules/archive" size="0" last-modified="2012-06-15T20:10:51Z">dir2/</entry><entry xmlns="http://www.zorba-xquery.com/modules/archive" size="6" last-modified="2012-06-15T20:10:47Z">file1</entry>
567\ No newline at end of file
568+<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>
569\ No newline at end of file
570
571=== modified file 'test/ExpQueryResults/entries_02.xml.res'
572--- test/ExpQueryResults/entries_02.xml.res 2012-08-03 21:54:38 +0000
573+++ test/ExpQueryResults/entries_02.xml.res 2012-12-21 22:13:22 +0000
574@@ -1,2 +1,2 @@
575 <?xml version="1.0" encoding="UTF-8"?>
576-<entry xmlns="http://www.zorba-xquery.com/modules/archive" size="0" last-modified="2012-06-15T20:11:09Z">dir1/</entry><entry xmlns="http://www.zorba-xquery.com/modules/archive" size="11" last-modified="2012-06-15T20:11:09Z">dir1/file1</entry><entry xmlns="http://www.zorba-xquery.com/modules/archive" size="11" last-modified="2012-06-15T20:11:03Z">dir1/file2</entry><entry xmlns="http://www.zorba-xquery.com/modules/archive" size="0" last-modified="2012-06-15T20:10:51Z">dir2/</entry><entry xmlns="http://www.zorba-xquery.com/modules/archive" size="6" last-modified="2012-06-15T20:10:47Z">file1</entry>
577\ No newline at end of file
578+<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>
579\ No newline at end of file
580
581=== modified file 'test/ExpQueryResults/entries_03.xml.res'
582--- test/ExpQueryResults/entries_03.xml.res 2012-08-03 21:54:38 +0000
583+++ test/ExpQueryResults/entries_03.xml.res 2012-12-21 22:13:22 +0000
584@@ -1,1 +1,1 @@
585-<entry xmlns="http://www.zorba-xquery.com/modules/archive" last-modified="2012-06-15T20:11:09Z" size="0">dir1/</entry><entry xmlns="http://www.zorba-xquery.com/modules/archive" last-modified="2012-06-15T20:11:09Z" size="11">dir1/file1</entry><entry xmlns="http://www.zorba-xquery.com/modules/archive" last-modified="2012-06-15T20:11:03Z" size="11">dir1/file2</entry><entry xmlns="http://www.zorba-xquery.com/modules/archive" last-modified="2012-06-15T20:10:51Z" size="0">dir2/</entry><entry xmlns="http://www.zorba-xquery.com/modules/archive" last-modified="2012-06-15T20:10:47Z" size="6">file1</entry>
586+<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>
587
588=== added file 'test/ExpQueryResults/options_02.xml.res'
589--- test/ExpQueryResults/options_02.xml.res 1970-01-01 00:00:00 +0000
590+++ test/ExpQueryResults/options_02.xml.res 2012-12-21 22:13:22 +0000
591@@ -0,0 +1,2 @@
592+<?xml version="1.0" encoding="UTF-8"?>
593+<options xmlns="http://www.zorba-xquery.com/modules/archive"><format>TAR</format><compression>BZIP2</compression></options>
594\ No newline at end of file
595
596=== added file 'test/ExpQueryResults/update_02.xml.res'
597--- test/ExpQueryResults/update_02.xml.res 1970-01-01 00:00:00 +0000
598+++ test/ExpQueryResults/update_02.xml.res 2012-12-21 22:13:22 +0000
599@@ -0,0 +1,2 @@
600+<?xml version="1.0" encoding="UTF-8"?>
601+3 &lt;foo2/&gt;
602\ No newline at end of file
603
604=== added file 'test/ExpQueryResults/update_03.xml.res'
605--- test/ExpQueryResults/update_03.xml.res 1970-01-01 00:00:00 +0000
606+++ test/ExpQueryResults/update_03.xml.res 2012-12-21 22:13:22 +0000
607@@ -0,0 +1,1 @@
608+<D:\zorba\code\zorba_modules\archive-module\test\Queries\update_03.xq>:10,21: user-defined error [http://www.zorba-xquery.com/modules/archive#ARCH0001]: number of entries (2) doesn't match number of content arguments (1); raised at D:\zorba\code\zorba_modules\archive-module\src\archive_module.xq.src\archive_module.cpp:686
609
610=== added file 'test/Queries/dir_01.xq'
611--- test/Queries/dir_01.xq 1970-01-01 00:00:00 +0000
612+++ test/Queries/dir_01.xq 2012-12-21 22:13:22 +0000
613@@ -0,0 +1,10 @@
614+import module namespace a = "http://www.zorba-xquery.com/modules/archive";
615+
616+let $foo-content := "<foo/>"
617+let $bar-content := "<bar/>"
618+let $archive := a:create(
619+ ("foo.xml", "bar.xml", <entry type="directory">dir1</entry>),
620+ ($foo-content, $bar-content)
621+)
622+return
623+ for $e in a:entries($archive) return concat($e/text(), ",")
624
625=== added file 'test/Queries/dir_02.xq'
626--- test/Queries/dir_02.xq 1970-01-01 00:00:00 +0000
627+++ test/Queries/dir_02.xq 2012-12-21 22:13:22 +0000
628@@ -0,0 +1,11 @@
629+import module namespace a = "http://www.zorba-xquery.com/modules/archive";
630+
631+let $foo-content := "<foo/>"
632+let $bar-content := "<bar/>"
633+let $archive := a:create(
634+ ("foo.xml", "bar.xml", <entry type="directory">dir1</entry>),
635+ ($foo-content, $bar-content)
636+)
637+let $archive2 := a:delete($archive, "dir1/")
638+return
639+ for $e in a:entries($archive2) return concat($e/text(), ",")
640
641=== added file 'test/Queries/dir_03.xq'
642--- test/Queries/dir_03.xq 1970-01-01 00:00:00 +0000
643+++ test/Queries/dir_03.xq 2012-12-21 22:13:22 +0000
644@@ -0,0 +1,13 @@
645+import module namespace a = "http://www.zorba-xquery.com/modules/archive";
646+
647+let $foo-content := "<foo/>"
648+let $bar-content := "<bar/>"
649+let $archive := a:create(
650+ ("foo.xml", "bar.xml", <entry type="directory">dir1</entry>),
651+ ($foo-content, $bar-content)
652+)
653+let $archive2 := a:delete($archive, "nonexistent.xml")
654+let $entries := a:entries($archive)
655+let $entries2 := a:entries($archive2)
656+return $entries=$entries2
657+
658
659=== added file 'test/Queries/dir_04.xq'
660--- test/Queries/dir_04.xq 1970-01-01 00:00:00 +0000
661+++ test/Queries/dir_04.xq 2012-12-21 22:13:22 +0000
662@@ -0,0 +1,13 @@
663+import module namespace a = "http://www.zorba-xquery.com/modules/archive";
664+
665+let $foo-content := "<foo/>"
666+let $bar-content := "<bar/>"
667+let $archive := a:create(
668+ ("foo.xml", "bar.xml", <entry type="directory">dir1</entry>),
669+ ($foo-content, $bar-content)
670+)
671+let $archive2 := a:update($archive, <a:entry type="directory">newdir</a:entry>, ())
672+let $entries := a:entries($archive)
673+let $entries2 := a:entries($archive2)
674+return for $e in $entries2 return concat($e/text(), ",")
675+
676
677=== added file 'test/Queries/entries_03.spec'
678--- test/Queries/entries_03.spec 1970-01-01 00:00:00 +0000
679+++ test/Queries/entries_03.spec 2012-12-21 22:13:22 +0000
680@@ -0,0 +1,1 @@
681+Error: http://www.zorba-xquery.com/modules/archive:ARCH9999
682
683=== added file 'test/Queries/options_02.spec'
684--- test/Queries/options_02.spec 1970-01-01 00:00:00 +0000
685+++ test/Queries/options_02.spec 2012-12-21 22:13:22 +0000
686@@ -0,0 +1,1 @@
687+Error: http://www.zorba-xquery.com/modules/archive:ARCH9999
688
689=== added file 'test/Queries/options_02.xq'
690--- test/Queries/options_02.xq 1970-01-01 00:00:00 +0000
691+++ test/Queries/options_02.xq 2012-12-21 22:13:22 +0000
692@@ -0,0 +1,5 @@
693+import module namespace a = "http://www.zorba-xquery.com/modules/archive";
694+import module namespace f = "http://expath.org/ns/file";
695+
696+let $tar-bz2 := f:read-binary(fn:resolve-uri("simple.tar.bz2"))
697+return a:options($tar-bz2)
698
699=== added file 'test/Queries/options_03.spec'
700--- test/Queries/options_03.spec 1970-01-01 00:00:00 +0000
701+++ test/Queries/options_03.spec 2012-12-21 22:13:22 +0000
702@@ -0,0 +1,1 @@
703+Error: http://www.zorba-xquery.com/modules/archive:ARCH9999
704
705=== added file 'test/Queries/options_03.xq'
706--- test/Queries/options_03.xq 1970-01-01 00:00:00 +0000
707+++ test/Queries/options_03.xq 2012-12-21 22:13:22 +0000
708@@ -0,0 +1,5 @@
709+import module namespace a = "http://www.zorba-xquery.com/modules/archive";
710+
711+let $fake_archive := xs:base64Binary("5Pb8")
712+return
713+ a:options($fake_archive)
714
715=== added file 'test/Queries/update_02.xq'
716--- test/Queries/update_02.xq 1970-01-01 00:00:00 +0000
717+++ test/Queries/update_02.xq 2012-12-21 22:13:22 +0000
718@@ -0,0 +1,12 @@
719+import module namespace a = "http://www.zorba-xquery.com/modules/archive";
720+import module namespace b = "http://www.zorba-xquery.com/modules/converters/base64";
721+
722+let $foo-content := "<foo/>"
723+let $bar-content := xs:base64Binary("YWJj")
724+let $archive := a:create(
725+ ("foo.xml", "bar.txt"),
726+ ($foo-content, $bar-content)
727+)
728+let $new-archive := a:update($archive, "foo2.xml", "<foo2/>")
729+return (count(a:entries($new-archive)), a:extract-text($new-archive, "foo2.xml"))
730+
731
732=== added file 'test/Queries/update_03.spec'
733--- test/Queries/update_03.spec 1970-01-01 00:00:00 +0000
734+++ test/Queries/update_03.spec 2012-12-21 22:13:22 +0000
735@@ -0,0 +1,1 @@
736+Error: http://www.zorba-xquery.com/modules/archive:ARCH0001
737
738=== added file 'test/Queries/update_03.xq'
739--- test/Queries/update_03.xq 1970-01-01 00:00:00 +0000
740+++ test/Queries/update_03.xq 2012-12-21 22:13:22 +0000
741@@ -0,0 +1,12 @@
742+import module namespace a = "http://www.zorba-xquery.com/modules/archive";
743+import module namespace b = "http://www.zorba-xquery.com/modules/converters/base64";
744+
745+let $foo-content := "<foo/>"
746+let $bar-content := xs:base64Binary("YWJj")
747+let $archive := a:create(
748+ ("foo.xml", "bar.txt"),
749+ ($foo-content, $bar-content)
750+)
751+let $new-archive := a:update($archive, ("foo2.xml", "bar2.xml"), ("<foo2/>"))
752+return (count(a:entries($new-archive)), a:extract-text($new-archive, "foo2.xml"))
753+
754
755=== added file 'test/Queries/update_04.spec'
756--- test/Queries/update_04.spec 1970-01-01 00:00:00 +0000
757+++ test/Queries/update_04.spec 2012-12-21 22:13:22 +0000
758@@ -0,0 +1,1 @@
759+Error: http://www.zorba-xquery.com/modules/archive:ARCH9999
760
761=== added file 'test/Queries/update_04.xq'
762--- test/Queries/update_04.xq 1970-01-01 00:00:00 +0000
763+++ test/Queries/update_04.xq 2012-12-21 22:13:22 +0000
764@@ -0,0 +1,7 @@
765+import module namespace a = "http://www.zorba-xquery.com/modules/archive";
766+import module namespace b = "http://www.zorba-xquery.com/modules/converters/base64";
767+
768+let $fake_archive := xs:base64Binary("YWJj")
769+let $new-archive := a:update($fake_archive, "foo2.xml", "<foo2/>")
770+return (count(a:entries($new-archive)), a:extract-text($new-archive, "foo2.xml"))
771+

Subscribers

People subscribed via source and target branches

to all changes: