Mercurial > hg > octave-lyh
annotate scripts/miscellaneous/bzip2.m @ 12500:8f2056646dba
Improve docstrings for archive functions (gzip, bzip2, etc.)
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Thu, 03 Mar 2011 13:05:50 -0800 |
parents | c792872f8942 |
children | f96b9b9f141b |
rev | line source |
---|---|
11523 | 1 ## Copyright (C) 2008-2011 Thorsten Meyer |
8349 | 2 ## (based on gzip.m by David Bateman) |
3 ## | |
4 ## This file is part of Octave. | |
5 ## | |
6 ## Octave is free software; you can redistribute it and/or modify it | |
7 ## under the terms of the GNU General Public License as published by | |
8 ## the Free Software Foundation; either version 3 of the License, or (at | |
9 ## your option) any later version. | |
10 ## | |
11 ## Octave is distributed in the hope that it will be useful, but | |
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 ## General Public License for more details. | |
15 ## | |
16 ## You should have received a copy of the GNU General Public License | |
17 ## along with Octave; see the file COPYING. If not, see | |
18 ## <http://www.gnu.org/licenses/>. | |
19 | |
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 | 22 ## @deftypefnx {Function File} {@var{entries} =} bzip2 (@var{files}, @var{outdir}) |
23 ## Compress the list of files specified in @var{files}. | |
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 |
8f2056646dba
Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
26 ## are silently overwritten. If @var{outdir} is defined the compressed |
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 | 29 ## @end deftypefn |
30 | |
31 function entries = bzip2 (varargin) | |
32 | |
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 | 39 else |
40 print_usage (); | |
41 endif | |
42 | |
43 endfunction | |
8362
03b414516dd8
clean up bzip2, gzip and __xzip__
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8349
diff
changeset
|
44 |
03b414516dd8
clean up bzip2, gzip and __xzip__
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8349
diff
changeset
|
45 %!xtest |
03b414516dd8
clean up bzip2, gzip and __xzip__
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8349
diff
changeset
|
46 %! # test for correct cleanup of temporary files |
03b414516dd8
clean up bzip2, gzip and __xzip__
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8349
diff
changeset
|
47 %! unwind_protect |
03b414516dd8
clean up bzip2, gzip and __xzip__
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8349
diff
changeset
|
48 %! filename = tmpnam; |
03b414516dd8
clean up bzip2, gzip and __xzip__
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8349
diff
changeset
|
49 %! dummy = 1; |
03b414516dd8
clean up bzip2, gzip and __xzip__
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8349
diff
changeset
|
50 %! save(filename, "dummy"); |
03b414516dd8
clean up bzip2, gzip and __xzip__
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8349
diff
changeset
|
51 %! n_tmpfiles_before = length(find(strncmp("oct-", cellstr(ls(P_tmpdir)), 4))); |
03b414516dd8
clean up bzip2, gzip and __xzip__
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8349
diff
changeset
|
52 %! entry = bzip2(filename); |
03b414516dd8
clean up bzip2, gzip and __xzip__
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8349
diff
changeset
|
53 %! n_tmpfiles_after = length(find(strncmp("oct-", cellstr(ls(P_tmpdir)), 4))); |
03b414516dd8
clean up bzip2, gzip and __xzip__
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8349
diff
changeset
|
54 %! if (n_tmpfiles_before != n_tmpfiles_after) |
03b414516dd8
clean up bzip2, gzip and __xzip__
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8349
diff
changeset
|
55 %! error("bzip2 has not cleaned up temporary files correctly!"); |
03b414516dd8
clean up bzip2, gzip and __xzip__
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8349
diff
changeset
|
56 %! endif |
03b414516dd8
clean up bzip2, gzip and __xzip__
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8349
diff
changeset
|
57 %! unwind_protect_cleanup |
03b414516dd8
clean up bzip2, gzip and __xzip__
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8349
diff
changeset
|
58 %! delete(filename); |
03b414516dd8
clean up bzip2, gzip and __xzip__
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8349
diff
changeset
|
59 %! [path, basename, extension] = fileparts(filename); |
03b414516dd8
clean up bzip2, gzip and __xzip__
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8349
diff
changeset
|
60 %! delete([basename, extension, ".bz2"]); |
03b414516dd8
clean up bzip2, gzip and __xzip__
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8349
diff
changeset
|
61 %! end_unwind_protect |