www.gusucode.com > appdesigner工具箱matlab源码程序 > appdesigner/+appdesigner/+internal/+application/getAppData.m

    function [loadOutcome, componentAndGroupData, appNameData, codeData] = getAppData(filepath)
% GETAPPDATA Facade APIs for App Designer client side getting app data
%
% Retrieve the data of the App of file - "filepath".  This
% is called by the client when the user chooses an App to open.

% Copyright 2016 The MathWorks, Inc.

% Assume load will be successful
loadOutcome.Status = 'success';

componentAndGroupData = [];
appNameData = [];
codeData = [];

% verify the file exists.
if exist(filepath, 'file') ~= 2
    % Error Message
    loadOutcome.Message = message('MATLAB:appdesigner:appdesigner:InvalidFileName', filepath).getString();
    loadOutcome.Status = 'error';
else
    % extract the appName from the file name.  This will be passed
    % back to the client.
    [~, appName] =  fileparts(filepath);
    
    try
        % retrieve the component data for the app.
        appLoadingFactory = appdesigner.internal.serialization.AppLoadingFactory.instance();
        appData = appLoadingFactory.getAppData(filepath);
        loadOutcome.CompatibilityData = appdesigner.internal.serialization.app.getAppCompatibilityData(appData);
        
        % if the loaded app does not meet the minimum supported version
        % throw an error
        if (isequal(loadOutcome.CompatibilityData.CompatibilityType, appdesigner.internal.serialization.app.CompatibilityTypes.UNSUPPORTED))
            error(message('MATLAB:appdesigner:appdesigner:IncompatibleAppVersion'));
        end
        
        % convert the enum type to char for the client
        loadOutcome.CompatibilityData.CompatibilityType = char(loadOutcome.CompatibilityData.CompatibilityType);
        
        [componentAndGroupData, codeData, SerializedAppName] = appLoadingFactory.retrieveAppDataForLoad(appData);
        appNameData = struct('AppName', appName, 'SerializedAppName', SerializedAppName);
    catch me
        % Error Message
        loadOutcome.Message = me.message;
        loadOutcome.Status = 'error';
    end
end
end