function varargout = zip(zipFilename,files,varargin)

narginchk(2,3);
nargoutchk(0,1);

[zipFilename,files,varargin{1:nargin-2}] = convertStringsToChars(zipFilename,files,varargin{:});

% Parse arguments.
[files, rootDir, zipFilename] =  ...
    matlab.io.internal.archive.parseArchiveInputs(mfilename, zipFilename,  files, varargin{:});

% Create the archive
try
    entries = matlab.io.internal.archive.getArchiveEntries(files, rootDir, mfilename, true);
    matlab.io.internal.archive.checkDuplicateEntries(entries, mfilename);
    entries = matlab.io.internal.archive.filterOutArchiveFile(entries, zipFilename, mfilename);
    matlab.io.internal.archive.checkEmptyEntries(entries, mfilename);
    archive = matlab.io.internal.archive.core.builtin.createArchive(zipFilename,{entries.file},{entries.entry},mfilename);
catch exception
    throw(exception);
end

if nargout == 1
    varargout{1} = archive;
end

% Copyright 1984-2023 The MathWorks, Inc.

