Mercurial > octave-antonio
annotate scripts/miscellaneous/tar.m @ 16403:1de4ec2a856d
Matlab compatibility for strsplit()
* scripts/strings/strsplit.m: Matlab compatible version.
* NEWS: Mention break in backward compatibility.
* scripts/deprecated/javafields.m: Modify call to strsplit().
* scripts/deprecated/javamethods.m: ditto
* scripts/general/fieldnames.m: ditto
* scripts/general/int2str.m: ditto
* scripts/general/methods.m: ditto
* scripts/general/num2str.m: ditto
* scripts/help/gen_doc_cache.m: ditto
* scripts/help/help.m: ditto
* scripts/help/lookfor.m: ditto
* scripts/io/strread.m: ditto
* scripts/java/javaclasspath.m: ditto
* scripts/miscellaneous/compare_versions.m: ditto
* scripts/miscellaneous/computer.m: ditto
* scripts/miscellaneous/fact.m: ditto
* scripts/miscellaneous/tar.m: ditto
* scripts/miscellaneous/unpack.m: ditto
* scripts/miscellaneous/what.m: ditto
* scripts/miscellaneous/zip.m: ditto
* scripts/pkg/private/configure_make.m: ditto
* scripts/pkg/private/fix_depends.m: ditto
* scripts/pkg/private/generate_lookfor_cache.m: ditto
* scripts/pkg/private/list_forge_packages.m: ditto
* scripts/pkg/private/unload_packages.m: ditto
* scripts/pkg/private/write_index.m: ditto
* scripts/plot/private/__file_filter__.m: ditto
* scripts/plot/private/__fltk_file_filter__.m: ditto
* scripts/plot/private/__go_draw_axes__.m: ditto
* scripts/plot/private/__next_line_style__.m: ditto
* scripts/strings/untabify.m: ditto
* scripts/testfun/rundemos.m: ditto
* scripts/testfun/runtests.m: ditto
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Sun, 31 Mar 2013 19:19:04 -0400 |
parents | 72c96de7a403 |
children | b7667fcb9fbc |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
12950
diff
changeset
|
1 ## Copyright (C) 2005-2012 S�ren Hauberg |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
2 ## |
6049 | 3 ## This file is part of Octave. |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
6049 | 9 ## |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
14 ## | |
5807 | 15 ## You should have received a copy of the GNU General Public License |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
5807 | 18 |
19 ## -*- texinfo -*- | |
12500
8f2056646dba
Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
20 ## @deftypefn {Function File} {@var{entries} =} tar (@var{tarfile}, @var{files}) |
8f2056646dba
Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
21 ## @deftypefnx {Function File} {@var{entries} =} tar (@var{tarfile}, @var{files}, @var{root}) |
5808 | 22 ## Pack @var{files} @var{files} into the TAR archive @var{tarfile}. The |
23 ## list of files must be a string or a cell array of strings. | |
24 ## | |
5807 | 25 ## The optional argument @var{root} changes the relative path of @var{files} |
26 ## from the current directory. | |
27 ## | |
5808 | 28 ## If an output argument is requested the entries in the archive are |
29 ## returned in a cell array. | |
12500
8f2056646dba
Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
30 ## @seealso{untar, bzip2, gzip, zip} |
5807 | 31 ## @end deftypefn |
32 | |
5808 | 33 ## Author: S�ren Hauberg <hauberg@gmail.com> |
5807 | 34 |
12500
8f2056646dba
Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
35 function entries = tar (tarfile, files, root = ".") |
5808 | 36 |
12500
8f2056646dba
Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
37 if (nargin < 2 || nargin > 3) |
8f2056646dba
Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
38 print_usage (); |
8f2056646dba
Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
39 endif |
5807 | 40 |
12500
8f2056646dba
Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
41 if (ischar (files)) |
8f2056646dba
Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
42 files = cellstr (files); |
8f2056646dba
Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
43 endif |
5807 | 44 |
12950
93a1d99183fb
tar.m: Fix validation of inputs (bug #33988)
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12500
diff
changeset
|
45 if (! (ischar (tarfile) && iscellstr (files) && ischar (root))) |
12500
8f2056646dba
Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
46 error ("tar: all arguments must be character strings"); |
8f2056646dba
Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
47 endif |
5808 | 48 |
12500
8f2056646dba
Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
49 cmd = sprintf ("tar cvf %s -C %s %s", tarfile, root, |
8f2056646dba
Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
50 sprintf (" %s", files{:})); |
8f2056646dba
Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
51 |
8f2056646dba
Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
52 [status, output] = system (cmd); |
5807 | 53 |
12500
8f2056646dba
Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
54 if (status) |
8f2056646dba
Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
55 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
|
56 endif |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
57 |
12500
8f2056646dba
Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
58 if (nargout > 0) |
8f2056646dba
Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
59 if (output(end) == "\n") |
8f2056646dba
Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
60 output(end) = []; |
5807 | 61 endif |
16403
1de4ec2a856d
Matlab compatibility for strsplit()
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
62 entries = strsplit (output, "\n", false); |
12500
8f2056646dba
Improve docstrings for archive functions (gzip, bzip2, etc.)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
63 entries = entries'; |
5808 | 64 endif |
65 | |
5807 | 66 endfunction |