4265
|
1 ## Copyright (C) 2003 John W. Eaton |
|
2 ## |
|
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 |
|
7 ## the Free Software Foundation; either version 2, or (at your option) |
|
8 ## any later version. |
|
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 ## |
|
15 ## You should have received a copy of the GNU General Public License |
|
16 ## along with Octave; see the file COPYING. If not, write to the Free |
5307
|
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
18 ## 02110-1301, USA. |
4265
|
19 |
|
20 ## -*- texinfo -*- |
4350
|
21 ## @deftypefn {Function File} {@var{filename} =} fullfile (@var{dir1}, @var{dir2}, @dots{}, @var{file}) |
|
22 ## Return a complete filename constructed from the given components. |
5835
|
23 ## @seealso{fileparts} |
4265
|
24 ## @end deftypefn |
|
25 |
|
26 function filename = fullfile (varargin) |
|
27 |
|
28 if (nargin > 0) |
|
29 filename = varargin{1}; |
4683
|
30 if (length (filename) < 1) |
|
31 filename = "."; |
|
32 endif |
5595
|
33 if (strcmp (filename(end), filesep)) |
4265
|
34 filename(end) = ""; |
|
35 endif |
|
36 for i = 2:nargin |
|
37 tmp = varargin{i}; |
5595
|
38 if (strcmp (tmp(1), filesep)) |
4265
|
39 tmp(1) = ""; |
|
40 endif |
5595
|
41 if (i < nargin && strcmp (tmp(end), filesep)) |
4265
|
42 tmp(end) = ""; |
|
43 endif |
|
44 filename = strcat (filename, filesep, tmp); |
|
45 endfor |
|
46 else |
|
47 usage ("fullfile (dir1, dir2, ..., file)"); |
|
48 endif |
|
49 |
|
50 endfunction |