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

%   Copyright (c) 1984-98 by The MathWorks, Inc.
%   $Revision: 1.7 $  $Date: 1997/11/21 23:31:17 $

% 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 == mldirsep(files));
      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

% --------------------------------------------------------- %
function str = mldirsep(deletefile)
%MLDIRSEP   Return the path seperator. 
%  The path seperator needs to be handled differently for VMS
if (isvms == 1)
  [t,r] = strtok(deletefile,']');
  if isempty(r)
    [t,r] = strtok(t,':');
    str = ':';
  else
    str = ']';
  end
else
  str = filesep;
end
