annotate scripts/miscellaneous/bzip2.m @ 14378:dbc99d17f0ad

fact.m: Spelling and punctuation fixes
author Jordi Gutiérrez Hermoso <jordigh@octave.org>
date Thu, 16 Feb 2012 21:44:53 -0500
parents f3d52523cde1
children 86854d032a37
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14138
72c96de7a403 maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents: 12642
diff changeset
1 ## Copyright (C) 2008-2012 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 -*-
10793
be55736a0783 Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents: 9245
diff changeset
21 ## @deftypefn {Function File} {@var{entries} =} bzip2 (@var{files})
8349
02beb5be5683 add bzip2 function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
diff changeset
22 ## @deftypefnx {Function File} {@var{entries} =} bzip2 (@var{files}, @var{outdir})
02beb5be5683 add bzip2 function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
diff changeset
23 ## Compress the list of files specified in @var{files}.
14359
7277fe922e99 doc: Use Octave preference for double quote in docstrings in scripts/
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
24 ## Each file is compressed separately and a new file with a ".bz2" extension
12500
8f2056646dba Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
25 ## is created. The original files are not modified. Existing compressed files
12642
f96b9b9f141b doc: Periodic grammarcheck and spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents: 12500
diff changeset
26 ## are silently overwritten. If @var{outdir} is defined the compressed
12500
8f2056646dba Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
27 ## files are placed in this directory.
8362
03b414516dd8 clean up bzip2, gzip and __xzip__
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 8349
diff changeset
28 ## @seealso{bunzip2, gzip, zip, tar}
8349
02beb5be5683 add bzip2 function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
diff changeset
29 ## @end deftypefn
02beb5be5683 add bzip2 function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
diff changeset
30
02beb5be5683 add bzip2 function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
diff changeset
31 function entries = bzip2 (varargin)
02beb5be5683 add bzip2 function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
diff changeset
32
02beb5be5683 add bzip2 function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
diff changeset
33 if (nargin == 1 || nargin == 2)
8362
03b414516dd8 clean up bzip2, gzip and __xzip__
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 8349
diff changeset
34 if nargout == 0
03b414516dd8 clean up bzip2, gzip and __xzip__
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 8349
diff changeset
35 __xzip__ ("bzip2", "bz2", "bzip2 %s", varargin{:});
03b414516dd8 clean up bzip2, gzip and __xzip__
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 8349
diff changeset
36 else
03b414516dd8 clean up bzip2, gzip and __xzip__
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 8349
diff changeset
37 entries = __xzip__ ("bzip2", "bz2", "bzip2 %s", varargin{:});
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
38 endif
8349
02beb5be5683 add bzip2 function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
diff changeset
39 else
02beb5be5683 add bzip2 function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
diff changeset
40 print_usage ();
02beb5be5683 add bzip2 function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
diff changeset
41 endif
02beb5be5683 add bzip2 function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
diff changeset
42
02beb5be5683 add bzip2 function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
diff changeset
43 endfunction
8362
03b414516dd8 clean up bzip2, gzip and __xzip__
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 8349
diff changeset
44
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
45
8362
03b414516dd8 clean up bzip2, gzip and __xzip__
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 8349
diff changeset
46 %!xtest
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
47 %! # test for correct cleanup of temporary files
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
48 %! unwind_protect
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
49 %! filename = tmpnam;
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
50 %! dummy = 1;
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
51 %! save (filename, "dummy");
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
52 %! n_tmpfiles_before = length (find (strncmp ("oct-", cellstr (ls (P_tmpdir)), 4)));
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
53 %! entry = bzip2 (filename);
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
54 %! n_tmpfiles_after = length (find (strncmp ("oct-", cellstr (ls (P_tmpdir)), 4)));
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
55 %! if (n_tmpfiles_before != n_tmpfiles_after)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
56 %! error ("bzip2 has not cleaned up temporary files correctly!");
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
57 %! endif
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
58 %! unwind_protect_cleanup
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
59 %! delete (filename);
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
60 %! [path, basename, extension] = fileparts (filename);
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
61 %! delete ([basename, extension, ".bz2"]);
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
62 %! end_unwind_protect
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
63