annotate scripts/miscellaneous/fullfile.m @ 7017:a1dbe9d80eee

[project @ 2007-10-12 21:27:11 by jwe]
author jwe
date Fri, 12 Oct 2007 21:27:37 +0000
parents 93c65f2a5668
children 1885f4c7e4b3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7017
a1dbe9d80eee [project @ 2007-10-12 21:27:11 by jwe]
jwe
parents: 7016
diff changeset
1 ## Copyright (C) 2003, 2005, 2006, 2007 John W. Eaton
4265
48897c78c52b [project @ 2003-01-03 06:04:29 by jwe]
jwe
parents:
diff changeset
2 ##
48897c78c52b [project @ 2003-01-03 06:04:29 by jwe]
jwe
parents:
diff changeset
3 ## This file is part of Octave.
48897c78c52b [project @ 2003-01-03 06:04:29 by jwe]
jwe
parents:
diff changeset
4 ##
48897c78c52b [project @ 2003-01-03 06:04:29 by jwe]
jwe
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
48897c78c52b [project @ 2003-01-03 06:04:29 by jwe]
jwe
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
8 ## your option) any later version.
4265
48897c78c52b [project @ 2003-01-03 06:04:29 by jwe]
jwe
parents:
diff changeset
9 ##
48897c78c52b [project @ 2003-01-03 06:04:29 by jwe]
jwe
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
48897c78c52b [project @ 2003-01-03 06:04:29 by jwe]
jwe
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
48897c78c52b [project @ 2003-01-03 06:04:29 by jwe]
jwe
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
48897c78c52b [project @ 2003-01-03 06:04:29 by jwe]
jwe
parents:
diff changeset
13 ## General Public License for more details.
48897c78c52b [project @ 2003-01-03 06:04:29 by jwe]
jwe
parents:
diff changeset
14 ##
48897c78c52b [project @ 2003-01-03 06:04:29 by jwe]
jwe
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
17 ## <http://www.gnu.org/licenses/>.
4265
48897c78c52b [project @ 2003-01-03 06:04:29 by jwe]
jwe
parents:
diff changeset
18
48897c78c52b [project @ 2003-01-03 06:04:29 by jwe]
jwe
parents:
diff changeset
19 ## -*- texinfo -*-
4350
b4661459eff7 [project @ 2003-02-21 19:29:43 by jwe]
jwe
parents: 4266
diff changeset
20 ## @deftypefn {Function File} {@var{filename} =} fullfile (@var{dir1}, @var{dir2}, @dots{}, @var{file})
b4661459eff7 [project @ 2003-02-21 19:29:43 by jwe]
jwe
parents: 4266
diff changeset
21 ## Return a complete filename constructed from the given components.
5835
07dd13bfc0ba [project @ 2006-05-31 18:21:49 by jwe]
jwe
parents: 5595
diff changeset
22 ## @seealso{fileparts}
4265
48897c78c52b [project @ 2003-01-03 06:04:29 by jwe]
jwe
parents:
diff changeset
23 ## @end deftypefn
48897c78c52b [project @ 2003-01-03 06:04:29 by jwe]
jwe
parents:
diff changeset
24
48897c78c52b [project @ 2003-01-03 06:04:29 by jwe]
jwe
parents:
diff changeset
25 function filename = fullfile (varargin)
48897c78c52b [project @ 2003-01-03 06:04:29 by jwe]
jwe
parents:
diff changeset
26
48897c78c52b [project @ 2003-01-03 06:04:29 by jwe]
jwe
parents:
diff changeset
27 if (nargin > 0)
48897c78c52b [project @ 2003-01-03 06:04:29 by jwe]
jwe
parents:
diff changeset
28 filename = varargin{1};
4683
a3a306af7292 [project @ 2003-12-23 05:48:02 by jwe]
jwe
parents: 4350
diff changeset
29 if (length (filename) < 1)
a3a306af7292 [project @ 2003-12-23 05:48:02 by jwe]
jwe
parents: 4350
diff changeset
30 filename = ".";
a3a306af7292 [project @ 2003-12-23 05:48:02 by jwe]
jwe
parents: 4350
diff changeset
31 endif
5595
83df01a26136 [project @ 2006-01-13 20:01:08 by jwe]
jwe
parents: 5307
diff changeset
32 if (strcmp (filename(end), filesep))
4265
48897c78c52b [project @ 2003-01-03 06:04:29 by jwe]
jwe
parents:
diff changeset
33 filename(end) = "";
48897c78c52b [project @ 2003-01-03 06:04:29 by jwe]
jwe
parents:
diff changeset
34 endif
48897c78c52b [project @ 2003-01-03 06:04:29 by jwe]
jwe
parents:
diff changeset
35 for i = 2:nargin
48897c78c52b [project @ 2003-01-03 06:04:29 by jwe]
jwe
parents:
diff changeset
36 tmp = varargin{i};
5595
83df01a26136 [project @ 2006-01-13 20:01:08 by jwe]
jwe
parents: 5307
diff changeset
37 if (strcmp (tmp(1), filesep))
4265
48897c78c52b [project @ 2003-01-03 06:04:29 by jwe]
jwe
parents:
diff changeset
38 tmp(1) = "";
48897c78c52b [project @ 2003-01-03 06:04:29 by jwe]
jwe
parents:
diff changeset
39 endif
5595
83df01a26136 [project @ 2006-01-13 20:01:08 by jwe]
jwe
parents: 5307
diff changeset
40 if (i < nargin && strcmp (tmp(end), filesep))
4265
48897c78c52b [project @ 2003-01-03 06:04:29 by jwe]
jwe
parents:
diff changeset
41 tmp(end) = "";
48897c78c52b [project @ 2003-01-03 06:04:29 by jwe]
jwe
parents:
diff changeset
42 endif
48897c78c52b [project @ 2003-01-03 06:04:29 by jwe]
jwe
parents:
diff changeset
43 filename = strcat (filename, filesep, tmp);
48897c78c52b [project @ 2003-01-03 06:04:29 by jwe]
jwe
parents:
diff changeset
44 endfor
48897c78c52b [project @ 2003-01-03 06:04:29 by jwe]
jwe
parents:
diff changeset
45 else
6046
34f96dd5441b [project @ 2006-10-10 16:10:25 by jwe]
jwe
parents: 5835
diff changeset
46 print_usage ();
4265
48897c78c52b [project @ 2003-01-03 06:04:29 by jwe]
jwe
parents:
diff changeset
47 endif
48897c78c52b [project @ 2003-01-03 06:04:29 by jwe]
jwe
parents:
diff changeset
48
48897c78c52b [project @ 2003-01-03 06:04:29 by jwe]
jwe
parents:
diff changeset
49 endfunction