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. |
4265
|
23 ## @end deftypefn |
|
24 |
|
25 function filename = fullfile (varargin) |
|
26 |
|
27 if (nargin > 0) |
|
28 filename = varargin{1}; |
4683
|
29 if (length (filename) < 1) |
|
30 filename = "."; |
|
31 endif |
5595
|
32 if (strcmp (filename(end), filesep)) |
4265
|
33 filename(end) = ""; |
|
34 endif |
|
35 for i = 2:nargin |
|
36 tmp = varargin{i}; |
5595
|
37 if (strcmp (tmp(1), filesep)) |
4265
|
38 tmp(1) = ""; |
|
39 endif |
5595
|
40 if (i < nargin && strcmp (tmp(end), filesep)) |
4265
|
41 tmp(end) = ""; |
|
42 endif |
|
43 filename = strcat (filename, filesep, tmp); |
|
44 endfor |
|
45 else |
|
46 usage ("fullfile (dir1, dir2, ..., file)"); |
|
47 endif |
|
48 |
|
49 endfunction |