1 ## Copyright (C) 2010-2012 Kai Habel
3 ## This file is part of Octave.
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 3 of the License, or (at
8 ## your option) any later version.
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.
15 ## You should have received a copy of the GNU General Public License
16 ## along with Octave; see the file COPYING. If not, see
17 ## <http://www.gnu.org/licenses/>.
20 ## @deftypefn {Function File} {} __file_filter__ (@var{file_filter})
21 ## Undocumented internal function.
26 function [retval, defname, defdir] = __file_filter__ (file_filter, name)
32 if (iscell (file_filter))
33 [r, c] = size (file_filter);
35 error ("%s: invalid filter specification", name);
40 retval{i, 1} = file_filter{i};
41 retval{i, 2} = __default_filtername__ (file_filter{i});
46 if (isempty (retval{i, 2}))
47 retval{i, 2} = __default_filtername__ (retval{i, 1});
51 elseif (ischar (file_filter))
52 [defdir, fname, fext] = fileparts (file_filter);
53 if (! strcmp (fname, "*"))
54 defname = strcat (fname, fext);
56 if (length (fext) > 0)
57 fext = strcat ("*", fext);
58 retval = {fext, __default_filtername__(fext)};
62 retval(end+1,:) = {"*", __default_filtername__("*")};
66 function name = __default_filtername__ (filterext)
74 name = "Octave Source Files";
76 name = "C Source Files";
77 case {"*.cc" "*.c++" "*.cpp"}
78 name = "C++ Source Files";
80 name = "Octave Compiled Files";
84 extlist = strsplit(filterext, ";");
85 extlist = strrep (extlist, "*.", "");
86 extlist = toupper (extlist);
87 extlist(end+1, :) = repmat ({","}, 1, length (extlist));
88 extlist = strcat (extlist{:});
89 extlist = extlist(1:end-1);
90 name = strcat (extlist, "-Files");