annotate scripts/miscellaneous/fullfile.m @ 5595:83df01a26136

[project @ 2006-01-13 20:01:08 by jwe]
author jwe
date Fri, 13 Jan 2006 20:01:09 +0000
parents 4c8a2e4e0717
children 07dd13bfc0ba
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4265
48897c78c52b [project @ 2003-01-03 06:04:29 by jwe]
jwe
parents:
diff changeset
1 ## Copyright (C) 2003 John W. Eaton
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
48897c78c52b [project @ 2003-01-03 06:04:29 by jwe]
jwe
parents:
diff changeset
7 ## the Free Software Foundation; either version 2, or (at your option)
48897c78c52b [project @ 2003-01-03 06:04:29 by jwe]
jwe
parents:
diff changeset
8 ## any later version.
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
48897c78c52b [project @ 2003-01-03 06:04:29 by jwe]
jwe
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, write to the Free
5307
4c8a2e4e0717 [project @ 2005-04-26 19:24:27 by jwe]
jwe
parents: 4683
diff changeset
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
4c8a2e4e0717 [project @ 2005-04-26 19:24:27 by jwe]
jwe
parents: 4683
diff changeset
18 ## 02110-1301, USA.
4265
48897c78c52b [project @ 2003-01-03 06:04:29 by jwe]
jwe
parents:
diff changeset
19
48897c78c52b [project @ 2003-01-03 06:04:29 by jwe]
jwe
parents:
diff changeset
20 ## -*- texinfo -*-
4350
b4661459eff7 [project @ 2003-02-21 19:29:43 by jwe]
jwe
parents: 4266
diff changeset
21 ## @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
22 ## Return a complete filename constructed from the given components.
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
48897c78c52b [project @ 2003-01-03 06:04:29 by jwe]
jwe
parents:
diff changeset
46 usage ("fullfile (dir1, dir2, ..., file)");
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