annotate scripts/miscellaneous/bzip2.m @ 20164:df437a52bcaf stable

doc: Update more docstrings to have one sentence summary as first line. Reviewed miscellaneous, sparse, strings in scripts directory. * scripts/miscellaneous/bzip2.m, scripts/miscellaneous/citation.m, scripts/miscellaneous/compare_versions.m, scripts/miscellaneous/computer.m, scripts/miscellaneous/debug.m, scripts/miscellaneous/dir.m, scripts/miscellaneous/edit.m, scripts/miscellaneous/error_ids.m, scripts/miscellaneous/fileattrib.m, scripts/miscellaneous/fullfile.m, scripts/miscellaneous/genvarname.m, scripts/miscellaneous/gzip.m, scripts/miscellaneous/mkoctfile.m, scripts/miscellaneous/news.m, scripts/miscellaneous/open.m, scripts/miscellaneous/parseparams.m, scripts/miscellaneous/recycle.m, scripts/miscellaneous/run.m, scripts/miscellaneous/swapbytes.m, scripts/miscellaneous/tar.m, scripts/miscellaneous/tmpnam.m, scripts/miscellaneous/unpack.m, scripts/miscellaneous/what.m, scripts/sparse/bicg.m, scripts/sparse/bicgstab.m, scripts/sparse/cgs.m, scripts/sparse/colperm.m, scripts/sparse/eigs.m, scripts/sparse/etreeplot.m, scripts/sparse/gmres.m, scripts/sparse/gplot.m, scripts/sparse/ichol.m, scripts/sparse/ilu.m, scripts/sparse/pcg.m, scripts/sparse/pcr.m, scripts/sparse/qmr.m, scripts/sparse/spaugment.m, scripts/sparse/spconvert.m, scripts/sparse/spdiags.m, scripts/sparse/spfun.m, scripts/sparse/spones.m, scripts/sparse/sprandsym.m, scripts/sparse/spstats.m, scripts/sparse/spy.m, scripts/sparse/svds.m, scripts/sparse/treelayout.m, scripts/sparse/treeplot.m, scripts/strings/base2dec.m, scripts/strings/bin2dec.m, scripts/strings/blanks.m, scripts/strings/cstrcat.m, scripts/strings/deblank.m, scripts/strings/dec2base.m, scripts/strings/dec2bin.m, scripts/strings/dec2hex.m, scripts/strings/findstr.m, scripts/strings/hex2dec.m, scripts/strings/index.m, scripts/strings/isletter.m, scripts/strings/isstrprop.m, scripts/strings/mat2str.m, scripts/strings/ostrsplit.m, scripts/strings/regexptranslate.m, scripts/strings/rindex.m, scripts/strings/str2num.m, scripts/strings/strcat.m, scripts/strings/strchr.m, scripts/strings/strjoin.m, scripts/strings/strjust.m, scripts/strings/strmatch.m, scripts/strings/strsplit.m, scripts/strings/strtok.m, scripts/strings/strtrim.m, scripts/strings/strtrunc.m, scripts/strings/substr.m, scripts/strings/untabify.m, scripts/time/datenum.m: Update more docstrings to have one sentence summary as first line.
author Rik <rik@octave.org>
date Mon, 04 May 2015 14:22:02 -0700
parents 4197fc428c7d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19697
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 19597
diff changeset
1 ## Copyright (C) 2008-2015 Thorsten Meyer
8349
02beb5be5683 add bzip2 function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
diff changeset
2 ## (based on gzip.m by David Bateman)
02beb5be5683 add bzip2 function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
diff changeset
3 ##
02beb5be5683 add bzip2 function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
diff changeset
4 ## This file is part of Octave.
02beb5be5683 add bzip2 function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
diff changeset
5 ##
02beb5be5683 add bzip2 function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
diff changeset
6 ## Octave is free software; you can redistribute it and/or modify it
02beb5be5683 add bzip2 function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
diff changeset
7 ## under the terms of the GNU General Public License as published by
02beb5be5683 add bzip2 function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
diff changeset
8 ## the Free Software Foundation; either version 3 of the License, or (at
02beb5be5683 add bzip2 function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
diff changeset
9 ## your option) any later version.
02beb5be5683 add bzip2 function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
diff changeset
10 ##
02beb5be5683 add bzip2 function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
diff changeset
11 ## Octave is distributed in the hope that it will be useful, but
02beb5be5683 add bzip2 function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
diff changeset
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of
02beb5be5683 add bzip2 function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
diff changeset
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
02beb5be5683 add bzip2 function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
diff changeset
14 ## General Public License for more details.
02beb5be5683 add bzip2 function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
diff changeset
15 ##
02beb5be5683 add bzip2 function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
diff changeset
16 ## You should have received a copy of the GNU General Public License
02beb5be5683 add bzip2 function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
diff changeset
17 ## along with Octave; see the file COPYING. If not, see
02beb5be5683 add bzip2 function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
diff changeset
18 ## <http://www.gnu.org/licenses/>.
02beb5be5683 add bzip2 function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
diff changeset
19
02beb5be5683 add bzip2 function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
diff changeset
20 ## -*- texinfo -*-
19258
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
21 ## @deftypefn {Function File} {@var{filelist} =} bzip2 (@var{files})
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
22 ## @deftypefnx {Function File} {@var{filelist} =} bzip2 (@var{files}, @var{dir})
8349
02beb5be5683 add bzip2 function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
diff changeset
23 ## Compress the list of files specified in @var{files}.
19258
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
24 ##
20164
df437a52bcaf doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
25 ## @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: 19697
diff changeset
26 ## 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: 19697
diff changeset
27 ## Each file is compressed separately and a new file with a @file{".bz2"}
df437a52bcaf doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
28 ## extension is created. The original files are not modified, but existing
df437a52bcaf doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
29 ## compressed files will be silently overwritten.
19258
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
30 ##
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
31 ## If @var{dir} is defined the compressed files are placed in this directory,
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
32 ## rather than the original directory where the uncompressed file resides.
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
33 ## If @var{dir} does not exist it is created.
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
34 ##
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
35 ## The optional output @var{filelist} is a list of the compressed files.
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
36 ## @seealso{bunzip2, unpack, gzip, zip, tar}
8349
02beb5be5683 add bzip2 function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
diff changeset
37 ## @end deftypefn
02beb5be5683 add bzip2 function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
diff changeset
38
19258
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
39 function filelist = bzip2 (varargin)
8349
02beb5be5683 add bzip2 function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
diff changeset
40
19258
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
41 if (nargin < 1 || nargin > 2 || nargout > 1)
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
42 print_usage ();
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
43 endif
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
44
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
45 if (nargout == 0)
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
46 __xzip__ ("bzip2", "bz2", "bzip2 %s", varargin{:});
8349
02beb5be5683 add bzip2 function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
diff changeset
47 else
19258
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
48 filelist = __xzip__ ("bzip2", "bz2", "bzip2 %s", varargin{:});
8349
02beb5be5683 add bzip2 function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
diff changeset
49 endif
02beb5be5683 add bzip2 function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
diff changeset
50
02beb5be5683 add bzip2 function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
diff changeset
51 endfunction
8362
03b414516dd8 clean up bzip2, gzip and __xzip__
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 8349
diff changeset
52
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
53
8362
03b414516dd8 clean up bzip2, gzip and __xzip__
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 8349
diff changeset
54 %!xtest
19258
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
55 %! ## test bzip2 together with bunzip2
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
56 %! unwind_protect
19258
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
57 %! filename = tempname;
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
58 %! dummy = pi;
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
59 %! save (filename, "dummy");
19258
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
60 %! dirname = tempname;
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
61 %! mkdir (dirname);
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
62 %! filelist = bzip2 (filename, dirname);
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
63 %! filelist = filelist{1};
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
64 %! [~, basename, extension] = fileparts (filename);
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
65 %! if (! strcmp (filelist, [dirname, filesep, basename, extension, ".bz2"]))
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
66 %! error ("bzipped file does not match expected name!");
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
67 %! endif
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
68 %! if (! exist (filelist, "file"))
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
69 %! error ("bzipped file cannot be found!");
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
70 %! endif
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
71 %! bunzip2 (filelist);
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
72 %! fid = fopen (filename, "rb");
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
73 %! assert (fid >= 0);
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
74 %! orig_data = fread (fid);
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
75 %! fclose (fid);
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
76 %! fid = fopen ([dirname filesep basename extension], "rb");
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
77 %! assert (fid >= 0);
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
78 %! new_data = fread (fid);
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
79 %! fclose (fid);
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
80 %! 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
81 %! error ("bunzipped file not equal to original file!");
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
82 %! endif
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
83 %! unwind_protect_cleanup
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
84 %! delete (filename);
19258
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
85 %! delete ([dirname, filesep, basename, extension]);
a4e993343e93 Overhaul the archive family (bzip2, gzip, zip, tar) of m-files.
Rik <rik@octave.org>
parents: 17744
diff changeset
86 %! rmdir (dirname);
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
87 %! end_unwind_protect
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
88