Mercurial > octave
annotate scripts/miscellaneous/tar.m @ 31247:3dae836c598c
doc: Expand and edit documentation for memoization (bug #60860)
author | Arun Giridhar <arungiridhar@gmail.com> |
---|---|
date | Fri, 30 Sep 2022 06:38:59 -0400 |
parents | 796f54d4ddbf |
children | 597f3ee61a48 |
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 ## |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
3 ## Copyright (C) 2005-2022 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
27331
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/>. |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
7 ## |
6049 | 8 ## This file is part of Octave. |
9 ## | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24096
diff
changeset
|
10 ## Octave is free software: you can redistribute it and/or modify it |
6049 | 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:
24096
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:
22323
diff
changeset
|
13 ## (at your option) any later version. |
6049 | 14 ## |
15 ## Octave is distributed in the hope that it will be useful, but | |
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
18 ## GNU General Public License for more details. |
6049 | 19 ## |
5807 | 20 ## You should have received a copy of the GNU General Public License |
7016 | 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:
24096
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 ######################################################################## |
5807 | 25 |
26 ## -*- texinfo -*- | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20164
diff
changeset
|
27 ## @deftypefn {} {@var{filelist} =} tar (@var{tarfile}, @var{files}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20164
diff
changeset
|
28 ## @deftypefnx {} {@var{filelist} =} tar (@var{tarfile}, @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 ## Pack 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 ## TAR archive @var{tarfile}. |
5808 | 31 ## |
20164
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19951
diff
changeset
|
32 ## @var{files} is a character array or cell array of strings. Shell wildcards |
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19951
diff
changeset
|
33 ## in the filename such as @samp{*} or @samp{?} are accepted and expanded. |
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19951
diff
changeset
|
34 ## Directories are recursively traversed and all files are added to the |
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19951
diff
changeset
|
35 ## archive. |
5807 | 36 ## |
19258
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{untar, unpack, bzip2, gzip, zip} |
5807 | 43 ## @end deftypefn |
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 = tar (tarfile, files, rootdir = ".") |
5808 | 46 |
28789
28de41192f3c
Eliminate unneeded verification of nargin, nargout in m-files.
Rik <rik@octave.org>
parents:
28087
diff
changeset
|
47 if (nargin < 2) |
12500
8f2056646dba
Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
48 print_usage (); |
8f2056646dba
Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
49 endif |
5807 | 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 (tarfile)) |
a4e993343e93
Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
52 error ("tar: TARFILE 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)) |
12500
8f2056646dba
Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
54 files = cellstr (files); |
19258
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 ("tar: FILES must be a character array or cellstr"); |
12500
8f2056646dba
Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
57 endif |
5807 | 58 |
19258
a4e993343e93
Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
59 rootdir = tilde_expand (rootdir); |
5808 | 60 |
19258
a4e993343e93
Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
61 tarfile = make_absolute_filename (tarfile); |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19535
diff
changeset
|
62 |
19951
8c20fb6caa16
Fix XFAIL with tar and unpack tests (bug #44007, bug #43979).
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
19927
diff
changeset
|
63 if (ispc) |
8c20fb6caa16
Fix XFAIL with tar and unpack tests (bug #44007, bug #43979).
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
19927
diff
changeset
|
64 ## Change tarfile into a mingw style acceptable for tar |
8c20fb6caa16
Fix XFAIL with tar and unpack tests (bug #44007, bug #43979).
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
19927
diff
changeset
|
65 tarfile = __w2mpth__ (tarfile); |
8c20fb6caa16
Fix XFAIL with tar and unpack tests (bug #44007, bug #43979).
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
19927
diff
changeset
|
66 endif |
8c20fb6caa16
Fix XFAIL with tar and unpack tests (bug #44007, bug #43979).
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
19927
diff
changeset
|
67 |
27331
3bf19af20af8
tar, untar, unpack: Add support for BSD tar (bug #53695)
Andrew Janke <andrew@apjanke.net>
parents:
26376
diff
changeset
|
68 ## BSD tar emits progress on stderr |
3bf19af20af8
tar, untar, unpack: Add support for BSD tar (bug #53695)
Andrew Janke <andrew@apjanke.net>
parents:
26376
diff
changeset
|
69 if (tar_is_bsd ()) |
3bf19af20af8
tar, untar, unpack: Add support for BSD tar (bug #53695)
Andrew Janke <andrew@apjanke.net>
parents:
26376
diff
changeset
|
70 cmd = sprintf ("tar cvf %s -C %s %s 2>&1", |
3bf19af20af8
tar, untar, unpack: Add support for BSD tar (bug #53695)
Andrew Janke <andrew@apjanke.net>
parents:
26376
diff
changeset
|
71 tarfile, rootdir, sprintf (" '%s'", files{:})); |
3bf19af20af8
tar, untar, unpack: Add support for BSD tar (bug #53695)
Andrew Janke <andrew@apjanke.net>
parents:
26376
diff
changeset
|
72 else |
3bf19af20af8
tar, untar, unpack: Add support for BSD tar (bug #53695)
Andrew Janke <andrew@apjanke.net>
parents:
26376
diff
changeset
|
73 cmd = sprintf ("tar cvf %s -C %s %s", |
3bf19af20af8
tar, untar, unpack: Add support for BSD tar (bug #53695)
Andrew Janke <andrew@apjanke.net>
parents:
26376
diff
changeset
|
74 tarfile, rootdir, sprintf (" %s", files{:})); |
28947
b73a54c31152
maint: Use Octave-specific end keywords rather than just 'end'.
Rik <rik@octave.org>
parents:
28892
diff
changeset
|
75 endif |
12500
8f2056646dba
Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
76 |
24096
8f3db1ac7877
tar, untar, unpack: ensure TAR_OPTIONS doesn't affect behavior (bug #52095)
Mike Miller <mtmiller@octave.org>
parents:
23220
diff
changeset
|
77 ## Save and restore the TAR_OPTIONS environment variable used by GNU tar. |
8f3db1ac7877
tar, untar, unpack: ensure TAR_OPTIONS doesn't affect behavior (bug #52095)
Mike Miller <mtmiller@octave.org>
parents:
23220
diff
changeset
|
78 tar_options_env = getenv ("TAR_OPTIONS"); |
8f3db1ac7877
tar, untar, unpack: ensure TAR_OPTIONS doesn't affect behavior (bug #52095)
Mike Miller <mtmiller@octave.org>
parents:
23220
diff
changeset
|
79 unwind_protect |
8f3db1ac7877
tar, untar, unpack: ensure TAR_OPTIONS doesn't affect behavior (bug #52095)
Mike Miller <mtmiller@octave.org>
parents:
23220
diff
changeset
|
80 unsetenv ("TAR_OPTIONS"); |
8f3db1ac7877
tar, untar, unpack: ensure TAR_OPTIONS doesn't affect behavior (bug #52095)
Mike Miller <mtmiller@octave.org>
parents:
23220
diff
changeset
|
81 [status, output] = system (cmd); |
8f3db1ac7877
tar, untar, unpack: ensure TAR_OPTIONS doesn't affect behavior (bug #52095)
Mike Miller <mtmiller@octave.org>
parents:
23220
diff
changeset
|
82 unwind_protect_cleanup |
8f3db1ac7877
tar, untar, unpack: ensure TAR_OPTIONS doesn't affect behavior (bug #52095)
Mike Miller <mtmiller@octave.org>
parents:
23220
diff
changeset
|
83 if (! isempty (tar_options_env)) |
8f3db1ac7877
tar, untar, unpack: ensure TAR_OPTIONS doesn't affect behavior (bug #52095)
Mike Miller <mtmiller@octave.org>
parents:
23220
diff
changeset
|
84 setenv ("TAR_OPTIONS", tar_options_env); |
8f3db1ac7877
tar, untar, unpack: ensure TAR_OPTIONS doesn't affect behavior (bug #52095)
Mike Miller <mtmiller@octave.org>
parents:
23220
diff
changeset
|
85 endif |
8f3db1ac7877
tar, untar, unpack: ensure TAR_OPTIONS doesn't affect behavior (bug #52095)
Mike Miller <mtmiller@octave.org>
parents:
23220
diff
changeset
|
86 end_unwind_protect |
5807 | 87 |
12500
8f2056646dba
Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
88 if (status) |
8f2056646dba
Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
89 error ("tar: tar exited with status = %d", status); |
8f2056646dba
Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
90 endif |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
91 |
12500
8f2056646dba
Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
92 if (nargout > 0) |
19927
0cc365dada52
Allow tar, unpack, and zip to run on Windows with CR/NL EOL.
Rik <rik@octave.org>
parents:
19925
diff
changeset
|
93 filelist = ostrsplit (output, "\r\n", true); |
19258
a4e993343e93
Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
94 filelist = filelist'; |
27331
3bf19af20af8
tar, untar, unpack: Add support for BSD tar (bug #53695)
Andrew Janke <andrew@apjanke.net>
parents:
26376
diff
changeset
|
95 |
3bf19af20af8
tar, untar, unpack: Add support for BSD tar (bug #53695)
Andrew Janke <andrew@apjanke.net>
parents:
26376
diff
changeset
|
96 ## BSD tar emits file actions in the first 2 columns |
3bf19af20af8
tar, untar, unpack: Add support for BSD tar (bug #53695)
Andrew Janke <andrew@apjanke.net>
parents:
26376
diff
changeset
|
97 if (tar_is_bsd ()) |
3bf19af20af8
tar, untar, unpack: Add support for BSD tar (bug #53695)
Andrew Janke <andrew@apjanke.net>
parents:
26376
diff
changeset
|
98 filelist = cellfun (@(x) x(3:end), filelist, 'UniformOutput', false); |
3bf19af20af8
tar, untar, unpack: Add support for BSD tar (bug #53695)
Andrew Janke <andrew@apjanke.net>
parents:
26376
diff
changeset
|
99 endif |
5808 | 100 endif |
101 | |
5807 | 102 endfunction |
17338
1c89599167a6
maint: End m-files with 1 blank line.
Rik <rik@octave.org>
parents:
17243
diff
changeset
|
103 |
19258
a4e993343e93
Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
104 |
25231
e1024058833c
test: change remaining %!xtests into %!tests
Mike Miller <mtmiller@octave.org>
parents:
25054
diff
changeset
|
105 ## FIXME: This test may fail if the tar command is not installed. If this |
e1024058833c
test: change remaining %!xtests into %!tests
Mike Miller <mtmiller@octave.org>
parents:
25054
diff
changeset
|
106 ## test fails, it might be better to change it into a testif with a |
e1024058833c
test: change remaining %!xtests into %!tests
Mike Miller <mtmiller@octave.org>
parents:
25054
diff
changeset
|
107 ## runtime condition on the tar program. |
e1024058833c
test: change remaining %!xtests into %!tests
Mike Miller <mtmiller@octave.org>
parents:
25054
diff
changeset
|
108 %!test |
19925
ee7159d9a330
tar.m: Re-code BIST test restore working directory even when test fails (bug #44007).
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
109 %! ## test tar together with untar |
19535
827cc33ae05c
avoid warning message in test for tar function
John W. Eaton <jwe@octave.org>
parents:
19258
diff
changeset
|
110 %! orig_dir = pwd (); |
19258
a4e993343e93
Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
111 %! unwind_protect |
19925
ee7159d9a330
tar.m: Re-code BIST test restore working directory even when test fails (bug #44007).
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
112 %! dirname = tarname = outdir = ""; |
ee7159d9a330
tar.m: Re-code BIST test restore working directory even when test fails (bug #44007).
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
113 %! dirname = tempname (); |
19258
a4e993343e93
Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
114 %! assert (mkdir (dirname)); |
19535
827cc33ae05c
avoid warning message in test for tar function
John W. Eaton <jwe@octave.org>
parents:
19258
diff
changeset
|
115 %! chdir (dirname); |
827cc33ae05c
avoid warning message in test for tar function
John W. Eaton <jwe@octave.org>
parents:
19258
diff
changeset
|
116 %! dirname2 = "dir2"; |
19258
a4e993343e93
Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
117 %! assert (mkdir (dirname2)); |
19925
ee7159d9a330
tar.m: Re-code BIST test restore working directory even when test fails (bug #44007).
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
118 %! fname1 = "file1"; |
ee7159d9a330
tar.m: Re-code BIST test restore working directory even when test fails (bug #44007).
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
119 %! fname2 = fullfile (dirname2, "file2"); |
19258
a4e993343e93
Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
120 %! fid = fopen (fname1, "wt"); |
a4e993343e93
Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
121 %! assert (fid >= 0); |
a4e993343e93
Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
122 %! fdisp (fid, "Hello World"); |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19535
diff
changeset
|
123 %! fclose (fid); |
19258
a4e993343e93
Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
124 %! fid = fopen (fname2, "wt"); |
a4e993343e93
Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
125 %! assert (fid >= 0); |
a4e993343e93
Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
126 %! fdisp (fid, "Goodbye World"); |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19535
diff
changeset
|
127 %! fclose (fid); |
19925
ee7159d9a330
tar.m: Re-code BIST test restore working directory even when test fails (bug #44007).
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
128 %! tarname = [tempname() ".tar"]; |
19258
a4e993343e93
Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
129 %! filelist = tar (tarname, {dirname2, fname1}); |
a4e993343e93
Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
130 %! if (! strcmp (filelist{3}, fname1)) |
a4e993343e93
Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
131 %! error ("tar file contents does not match expected file"); |
a4e993343e93
Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
132 %! endif |
a4e993343e93
Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
133 %! if (! exist (tarname, "file")) |
a4e993343e93
Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
134 %! error ("tar archive file cannot be found!"); |
a4e993343e93
Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
135 %! endif |
28892
3cac3ceb9629
maint: Use coding style with parentheses after function name to distinguish from a variable.
Rik <rik@octave.org>
parents:
28886
diff
changeset
|
136 %! outdir = tempname (); |
19258
a4e993343e93
Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
137 %! untar (tarname, outdir); |
a4e993343e93
Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
138 %! fid = fopen (fullfile (outdir, fname1), "rt"); |
a4e993343e93
Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
139 %! assert (fid >= 0); |
a4e993343e93
Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
140 %! str = fgetl (fid); |
a4e993343e93
Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
141 %! fclose (fid); |
a4e993343e93
Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
142 %! assert (str, "Hello World"); |
a4e993343e93
Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
143 %! fid = fopen (fullfile (outdir, fname2), "rt"); |
a4e993343e93
Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
144 %! assert (fid >= 0); |
a4e993343e93
Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
145 %! str = fgetl (fid); |
a4e993343e93
Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
146 %! fclose (fid); |
a4e993343e93
Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
147 %! assert (str, "Goodbye World"); |
a4e993343e93
Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
148 %! unwind_protect_cleanup |
19925
ee7159d9a330
tar.m: Re-code BIST test restore working directory even when test fails (bug #44007).
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
149 %! chdir (orig_dir); |
19927
0cc365dada52
Allow tar, unpack, and zip to run on Windows with CR/NL EOL.
Rik <rik@octave.org>
parents:
19925
diff
changeset
|
150 %! unlink (tarname); |
19258
a4e993343e93
Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
151 %! confirm_recursive_rmdir (false, "local"); |
28087
9cb04a9e81ec
rmdir: throw an error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents:
27978
diff
changeset
|
152 %! sts = rmdir (dirname, "s"); |
9cb04a9e81ec
rmdir: throw an error if operation fails and nargout == 0 (bug #57830).
Rik <rik@octave.org>
parents:
27978
diff
changeset
|
153 %! sts = rmdir (outdir, "s"); |
19258
a4e993343e93
Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
154 %! end_unwind_protect |
a4e993343e93
Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
155 |
a4e993343e93
Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
156 ## Test input validation |
28886
d8318c12d903
test: remove unnecessary BIST tests in m-files checking for excessive number of inputs.
Rik <rik@octave.org>
parents:
28789
diff
changeset
|
157 %!error <Invalid call> tar () |
d8318c12d903
test: remove unnecessary BIST tests in m-files checking for excessive number of inputs.
Rik <rik@octave.org>
parents:
28789
diff
changeset
|
158 %!error <Invalid call> tar (1) |
19258
a4e993343e93
Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
159 %!error <TARFILE must be a string> tar (1, "foobar") |
a4e993343e93
Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
160 %!error <FILES must be a character array or cellstr> tar ("foobar", 1) |