www.gusucode.com > mbctools 工具箱 matlab 源码程序 > mbctools/@mdevproject/load.m

    function [MP,msg]= load(MP,filename)
%LOAD
% 
%  [MP, MSG] = LOAD(MP, FILENAME)

%  Copyright 2000-2014 The MathWorks, Inc. and Ford Global Technologies, Inc.


msg= '';
[fok,varlist]= isProjectFile(MP,filename);

if ~fok
    msg= 'File not found or invalid format.';
    return;
end

CAN_LOAD = ~strcmp(varlist.class,'struct');

if CAN_LOAD 
    ws= warning('off','all');
    lastwarn('')
    % load file
    S= struct2cell(load(filename , '-mat'));
    warning(ws)
    MP= S{1};
    if ~isa(MP,'mdevproject') || ~isempty(MP.heap)
        [msg,id] = lastwarn;
        if ~isempty(msg) && strcmp(id,'MATLAB:loadobj')
            pos = strfind(msg,'</a>');
            if ~isempty(pos)
                msg = msg(pos(end)+6:end-1);
            end
        else
            msg= 'Invalid or corrupt file';
        end
    end
else
    msg= 'Unknown file type';
end


if isempty(msg)
    % register file 
    [MP,msg]= RegisterFile(MP,filename); 
end