annotate scripts/miscellaneous/zip.m @ 27978:a4268efb7334

maint: Eliminate single "Author:" lines from code base. * color-picker.cc, color-picker.h, octave-qscintilla.cc, octave-qscintilla.h, octave-txt-lexer.cc, octave-txt-lexer.h, balance.cc, kron.cc, lookup.cc, ls-hdf5.cc, ls-mat5.cc, ls-oct-text.cc, sylvester.cc, tsearch.cc, jit-ir.cc, jit-ir.h, jit-typeinfo.cc, jit-typeinfo.h, jit-util.cc, jit-util.h, pt-jit.cc, pt-jit.h, Array-jit.cc, bsxfun.h, url-transfer.cc, url-transfer.h, acosd.m, acotd.m, acscd.m, asecd.m, asind.m, atand.m, cosd.m, cotd.m, cscd.m, secd.m, sind.m, tand.m, cart2pol.m, cart2sph.m, curl.m, del2.m, divergence.m, flip.m, pol2cart.m, randi.m, sortrows.m, sph2cart.m, griddata3.m, griddatan.m, rectint.m, voronoi.m, dialog.m, guidata.m, guihandles.m, __file_filter__.m, __fltk_file_filter__.m, __get_funcname__.m, __is_function__.m, __uigetdir_fltk__.m, __uigetfile_fltk__.m, __uiobject_split_args__.m, __uiputfile_fltk__.m, uibuttongroup.m, uicontextmenu.m, uicontrol.m, uigetdir.m, uigetfile.m, uimenu.m, uipanel.m, uipushtool.m, uiputfile.m, uiresume.m, uitoggletool.m, uitoolbar.m, uiwait.m, doc.m, autumn.m, bone.m, cmpermute.m, cmunique.m, cool.m, copper.m, cubehelix.m, flag.m, frame2im.m, hot.m, hsv.m, hsv2rgb.m, im2frame.m, imfinfo.m, imformats.m, iscolormap.m, jet.m, pink.m, prism.m, __imfinfo__.m, rainbow.m, rgb2hsv.m, spinmap.m, spring.m, viridis.m, white.m, winter.m, importdata.m, strmatch.m, bandwidth.m, isbanded.m, isdiag.m, istril.m, istriu.m, krylov.m, linsolve.m, logm.m, lscov.m, subspace.m, bunzip2.m, compare_versions.m, edit.m, fullfile.m, getfield.m, gunzip.m, inputParser.m, license.m, nargchk.m, narginchk.m, nthargout.m, python.m, setfield.m, tar.m, unpack.m, ver.m, zip.m, odeplot.m, fminbnd.m, fminunc.m, fsolve.m, fzero.m, glpk.m, humps.m, pathdef.m, savepath.m, diffuse.m, lighting.m, material.m, shading.m, specular.m, contour.m, ellipsoid.m, isocaps.m, isocolors.m, isonormals.m, isosurface.m, light.m, pcolor.m, __interp_cube__.m, __marching_cube__.m, __patch__.m, __stem__.m, reducepatch.m, reducevolume.m, ribbon.m, shrinkfaces.m, slice.m, stem.m, surf.m, surfl.m, tetramesh.m, waterfall.m, __actual_axis_position__.m, __next_line_color__.m, allchild.m, figure.m, findall.m, findobj.m, gcf.m, hggroup.m, isprop.m, ndgrid.m, __add_default_menu__.m, saveas.m, __splinefit__.m, prefdir.m, preferences.m, profexplore.m, profexport.m, profile.m, profshow.m, setdiff.m, freqz.m, freqz_plot.m, sinc.m, unwrap.m, pcr.m, qmr.m, sprandn.m, betaincinv.m, cosint.m, ellipke.m, factor.m, gammaincinv.m, legendre.m, nchoosek.m, primes.m, invhilb.m, toeplitz.m, erase.m, mat2str.m, strtrim.m, validatestring.m, fail.m, compare_plot_demos.m, dump_demos.m, html_compare_plot_demos.m, addtodate.m, datenum.m, jit.tst: Eliminate single "Author:" lines from code base.
author Rik <rik@octave.org>
date Tue, 21 Jan 2020 12:53:13 -0800
parents bd51beb6205e
children 9cb04a9e81ec 0a5b15007766
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ########################################################################
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 ##
27919
1891570abac8 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 27918
diff changeset
3 ## Copyright (C) 2006-2020 The Octave Project Developers
27918
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
4 ##
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 ## See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 ## distribution or <https://octave.org/copyright/>.
6049
04c2ad6d1679 [project @ 2006-10-13 14:32:15 by jwe]
jwe
parents:
diff changeset
7 ##
04c2ad6d1679 [project @ 2006-10-13 14:32:15 by jwe]
jwe
parents:
diff changeset
8 ## This file is part of Octave.
04c2ad6d1679 [project @ 2006-10-13 14:32:15 by jwe]
jwe
parents:
diff changeset
9 ##
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24370
diff changeset
10 ## Octave is free software: you can redistribute it and/or modify it
6049
04c2ad6d1679 [project @ 2006-10-13 14:32:15 by jwe]
jwe
parents:
diff changeset
11 ## under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24370
diff changeset
12 ## the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22365
diff changeset
13 ## (at your option) any later version.
6049
04c2ad6d1679 [project @ 2006-10-13 14:32:15 by jwe]
jwe
parents:
diff changeset
14 ##
04c2ad6d1679 [project @ 2006-10-13 14:32:15 by jwe]
jwe
parents:
diff changeset
15 ## Octave is distributed in the hope that it will be useful, but
04c2ad6d1679 [project @ 2006-10-13 14:32:15 by jwe]
jwe
parents:
diff changeset
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22365
diff changeset
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22365
diff changeset
18 ## GNU General Public License for more details.
6049
04c2ad6d1679 [project @ 2006-10-13 14:32:15 by jwe]
jwe
parents:
diff changeset
19 ##
04c2ad6d1679 [project @ 2006-10-13 14:32:15 by jwe]
jwe
parents:
diff changeset
20 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6065
diff changeset
21 ## along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24370
diff changeset
22 ## <https://www.gnu.org/licenses/>.
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 ##
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ########################################################################
6049
04c2ad6d1679 [project @ 2006-10-13 14:32:15 by jwe]
jwe
parents:
diff changeset
25
04c2ad6d1679 [project @ 2006-10-13 14:32:15 by jwe]
jwe
parents:
diff changeset
26 ## -*- texinfo -*-
20852
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20082
diff changeset
27 ## @deftypefn {} {@var{filelist} =} zip (@var{zipfile}, @var{files})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20082
diff changeset
28 ## @deftypefnx {} {@var{filelist} =} zip (@var{zipfile}, @var{files}, @var{rootdir})
19258
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
29 ## Compress the list of files and directories specified in @var{files} into the
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
30 ## ZIP archive @var{zipfile}.
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
31 ##
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
32 ## @var{files} is a character array or cell array of strings. Shell
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
33 ## wildcards in the filename such as @samp{*} or @samp{?} are accepted and
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
34 ## expanded. Directories are recursively traversed and all files are
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
35 ## compressed and added to the archive.
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
36 ##
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
37 ## If @var{rootdir} is defined then any files without absolute pathnames are
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
38 ## located relative to @var{rootdir} rather than the current directory.
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
39 ##
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
40 ## The optional output @var{filelist} is a list of the files that were included
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
41 ## in the archive.
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
42 ## @seealso{unzip, unpack, bzip2, gzip, tar}
6049
04c2ad6d1679 [project @ 2006-10-13 14:32:15 by jwe]
jwe
parents:
diff changeset
43 ## @end deftypefn
04c2ad6d1679 [project @ 2006-10-13 14:32:15 by jwe]
jwe
parents:
diff changeset
44
19258
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
45 function filelist = zip (zipfile, files, rootdir = ".")
6049
04c2ad6d1679 [project @ 2006-10-13 14:32:15 by jwe]
jwe
parents:
diff changeset
46
19258
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
47 if (nargin < 2 || nargin > 3)
6049
04c2ad6d1679 [project @ 2006-10-13 14:32:15 by jwe]
jwe
parents:
diff changeset
48 print_usage ();
04c2ad6d1679 [project @ 2006-10-13 14:32:15 by jwe]
jwe
parents:
diff changeset
49 endif
04c2ad6d1679 [project @ 2006-10-13 14:32:15 by jwe]
jwe
parents:
diff changeset
50
19258
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
51 if (! ischar (zipfile))
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
52 error ("zip: ZIPFILE must be a string");
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
53 elseif (ischar (files))
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
54 files = cellstr (files);
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
55 elseif (! iscellstr (files))
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
56 error ("zip: FILES must be a character array or cellstr");
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
57 endif
19597
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19258
diff changeset
58
12500
8f2056646dba Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
59 rootdir = tilde_expand (rootdir);
8f2056646dba Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
60
19258
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
61 zipfile = make_absolute_filename (zipfile);
19597
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19258
diff changeset
62
21533
6187f1d2ca13 zip.m: Restore processing of wildcards partially lost in cset 50255c612915.
Rik <rik@octave.org>
parents: 21525
diff changeset
63 ## FIXME: This is a lot of processing that could be done by the shell
6187f1d2ca13 zip.m: Restore processing of wildcards partially lost in cset 50255c612915.
Rik <rik@octave.org>
parents: 21525
diff changeset
64 ## if Octave had a way to call system without passing a single string.
6187f1d2ca13 zip.m: Restore processing of wildcards partially lost in cset 50255c612915.
Rik <rik@octave.org>
parents: 21525
diff changeset
65 ## Escape bad shell characters
6187f1d2ca13 zip.m: Restore processing of wildcards partially lost in cset 50255c612915.
Rik <rik@octave.org>
parents: 21525
diff changeset
66 files = regexprep (files, "([|&;<>()$`\\'\" ])", '\\$1');
6187f1d2ca13 zip.m: Restore processing of wildcards partially lost in cset 50255c612915.
Rik <rik@octave.org>
parents: 21525
diff changeset
67 files = sprintf (' %s', files{:}); # convert to space separated list
6187f1d2ca13 zip.m: Restore processing of wildcards partially lost in cset 50255c612915.
Rik <rik@octave.org>
parents: 21525
diff changeset
68 zipfile = regexprep (zipfile, "'", "\\'"); # escape single quotes
6187f1d2ca13 zip.m: Restore processing of wildcards partially lost in cset 50255c612915.
Rik <rik@octave.org>
parents: 21525
diff changeset
69 cmd = sprintf ("zip -r '%s' %s", zipfile, files);
21586
3b9524234d89 zip.m: fix error when zipping files with backslash paths on Windows (bug #47609)
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 21582
diff changeset
70 if (ispc () && ! isunix ())
24370
b1d1229d9e83 maint: Use single quotes to simplify excessive backslash escapes in code.
Rik <rik@octave.org>
parents: 23220
diff changeset
71 cmd = strrep (cmd, '\', '/');
21586
3b9524234d89 zip.m: fix error when zipping files with backslash paths on Windows (bug #47609)
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 21582
diff changeset
72 endif
12500
8f2056646dba Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
73
20082
d6e523825abc zip.m: fix XFAIL on Windows; fix test (bug #44811).
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 19927
diff changeset
74 origdir = pwd ();
d6e523825abc zip.m: fix XFAIL on Windows; fix test (bug #44811).
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 19927
diff changeset
75 cd (rootdir);
12500
8f2056646dba Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
76 [status, output] = system (cmd);
20082
d6e523825abc zip.m: fix XFAIL on Windows; fix test (bug #44811).
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 19927
diff changeset
77 cd (origdir);
12500
8f2056646dba Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
78
8f2056646dba Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
79 if (status)
8f2056646dba Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
80 error ("zip: zip failed with exit status = %d", status);
8f2056646dba Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
81 endif
8f2056646dba Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
82
8f2056646dba Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
83 if (nargout > 0)
21582
fa58fcb7c51d zip.m: Fix zipping into directory with spaces.
Rik <rik@octave.org>
parents: 21533
diff changeset
84 cmd = sprintf ("unzip -Z -1 '%s'", zipfile);
19258
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
85 [status, filelist] = system (cmd);
12500
8f2056646dba Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
86 if (status)
8f2056646dba Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
87 error ("zip: zipinfo failed with exit status = %d", status);
8f2056646dba Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
88 endif
19927
0cc365dada52 Allow tar, unpack, and zip to run on Windows with CR/NL EOL.
Rik <rik@octave.org>
parents: 19697
diff changeset
89 filelist = ostrsplit (filelist, "\r\n", true);
12500
8f2056646dba Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
90 endif
8f2056646dba Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
91
6049
04c2ad6d1679 [project @ 2006-10-13 14:32:15 by jwe]
jwe
parents:
diff changeset
92 endfunction
17338
1c89599167a6 maint: End m-files with 1 blank line.
Rik <rik@octave.org>
parents: 16724
diff changeset
93
19258
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
94
25231
e1024058833c test: change remaining %!xtests into %!tests
Mike Miller <mtmiller@octave.org>
parents: 25054
diff changeset
95 ## FIXME: This test may fail if the zip or unzip command is not installed.
e1024058833c test: change remaining %!xtests into %!tests
Mike Miller <mtmiller@octave.org>
parents: 25054
diff changeset
96 ## If this test fails, it might be better to change it into a testif
e1024058833c test: change remaining %!xtests into %!tests
Mike Miller <mtmiller@octave.org>
parents: 25054
diff changeset
97 ## with a runtime condition on the zip and unzip programs.
e1024058833c test: change remaining %!xtests into %!tests
Mike Miller <mtmiller@octave.org>
parents: 25054
diff changeset
98 %!test
19258
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
99 %! ## test zip together with unzip
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
100 %! unwind_protect
19927
0cc365dada52 Allow tar, unpack, and zip to run on Windows with CR/NL EOL.
Rik <rik@octave.org>
parents: 19697
diff changeset
101 %! filename = tempname ();
19258
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
102 %! tmp_var = pi;
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
103 %! save (filename, "tmp_var");
19927
0cc365dada52 Allow tar, unpack, and zip to run on Windows with CR/NL EOL.
Rik <rik@octave.org>
parents: 19697
diff changeset
104 %! dirname = tempname ();
19258
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
105 %! mkdir (dirname);
19927
0cc365dada52 Allow tar, unpack, and zip to run on Windows with CR/NL EOL.
Rik <rik@octave.org>
parents: 19697
diff changeset
106 %! zipfile = tempname ();
19258
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
107 %! [~, basename, ext] = fileparts (filename);
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
108 %! filelist = zip (zipfile, [basename ext], tempdir);
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
109 %! filelist = filelist{1};
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
110 %! if (! strcmp (filelist, [basename ext]))
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
111 %! error ("zip archive does not contain expected name!");
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
112 %! endif
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
113 %! if (! exist ([zipfile ".zip"], "file"))
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
114 %! error ("zip file cannot be found!");
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
115 %! endif
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
116 %! unzip ([zipfile ".zip"], dirname);
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
117 %! fid = fopen (filename, "rb");
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
118 %! assert (fid >= 0);
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
119 %! orig_data = fread (fid);
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
120 %! fclose (fid);
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
121 %! fid = fopen ([dirname filesep basename ext], "rb");
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
122 %! assert (fid >= 0);
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
123 %! new_data = fread (fid);
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
124 %! fclose (fid);
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
125 %! if (orig_data != new_data)
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
126 %! error ("unzipped file not equal to original file!");
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
127 %! endif
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
128 %! unwind_protect_cleanup
19927
0cc365dada52 Allow tar, unpack, and zip to run on Windows with CR/NL EOL.
Rik <rik@octave.org>
parents: 19697
diff changeset
129 %! unlink (filename);
20082
d6e523825abc zip.m: fix XFAIL on Windows; fix test (bug #44811).
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 19927
diff changeset
130 %! unlink ([dirname, filesep, basename, ext]);
22365
119f408f2dd1 Remove temporary directories and files used by BIST.
Carnë Draug <carandraug@octave.org>
parents: 22323
diff changeset
131 %! unlink (zipfile);
119f408f2dd1 Remove temporary directories and files used by BIST.
Carnë Draug <carandraug@octave.org>
parents: 22323
diff changeset
132 %! unlink ([zipfile ".zip"]);
19258
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
133 %! rmdir (dirname);
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
134 %! end_unwind_protect
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
135
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
136 ## Test input validation
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
137 %!error zip ()
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
138 %!error zip (1)
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
139 %!error zip (1,2,3,4)
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
140 %!error <ZIPFILE must be a string> zip (1, "foobar")
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
141 %!error <FILES must be a character array or cellstr> zip ("foobar", 1)