www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/@cgproject/registerfile.m
function [PROJ,msg]= registerfile(PROJ,File) %REGISTERFILE Register project as being opened from a file % % [P, MSG] = REGISTERFILE(P, FILE) writes a "lock" file to disk to ensure % no one else can open a project file, and ensures that the project has the % same name as the file specified. % Copyright 2000-2016 The MathWorks, Inc. and Ford Global Technologies, Inc. [Newpath,Newfile] = fileparts(File); PROJ.filename = File; % save temp file msg = ''; tmpfile = fullfile(Newpath,['~',Newfile,'_cage.tmp']); try %#ok<TRYNC> tmpvar = 'FileOpened'; %#ok<NASGU> save(tmpfile,'tmpvar','-mat'); % allow file to be opened even if temp file fails end PROJ = setname(PROJ,Newfile); pointer(PROJ);