function delete(varargin)
%DELETE Delete files.
%   Implementation using DIR so that wildcards are supported.

%   Copyright 1984-2000 The MathWorks, Inc. 
%   $Revision: 1.9 $  $Date: 2000/06/01 01:25:12 $

% Set the path concatenation to be the current directory
dirpath = [];

% Delete all files in the argument list
for k=1:length(varargin)
  files = varargin{k};
  if ~isempty(files)

    % If there is a wildcard, get the path information and files
    if ~isempty(findstr(files,'*'))
      d = dir(files);

      % If the path was specified store it
      idx = find(files == filesep);
      if ~isempty(idx)
        dirpath = files(1:idx(end));
      end

      % Delete the appropriate file using the concatenated path info
      for i=1:length(d)
         builtin('delete', [dirpath d(i).name]);
      end

    % If the path to the file to be deleted is given, just use it
    else
        builtin('delete',files);
    end
  end
end