www.gusucode.com > mbcdata 工具箱 matlab 源码程序 > mbcdata/@calibrationdata/@calibrationinterface/hGetLocalFilename.m
function local = hGetLocalFilename(obj, remote, shareMap) %HGETLOCALFILENAME Helper method to resolve filenames. % % LOCAL = HGETLOCALFILENAME(CAL,REMOTE,SHAREMAP) converts a path REMOTE to % a file with respect to a remote machine into a path LOCAL with respect % to a local machine using a share map SHAREMAP. % % SHAREMAP is a mapping between local machines and remote machines. % SHAREMAP is an n-by-2 cell array with the first column containing path % stubs with respect to the remote machine and the second column % containing path stubs with respect to the local machine. For example, % if a file is stored on the remote machine REMOTE at % D:\calibrations\engine\1088\1088.dtv and that file is accessible from % the MATLAB machine MYLAPTOP using % \\REMOTE\D$\calibrations\engine\1088\1088.dtv, then a suitable SHAREMAP % would be {'D:\calibrations','\\REMOTE\D$\calibrations'} or even % {'D:','\\DYNOCOMPUTERNAME\D$'}. What if, from the perspective of % REMOTE, the data version is stored on a network drive at % W:\engine\1088\1088.dtv where W: is mapped to \\ENGINEERING\cals? If the % same mapping exists for W: on MYLAPTOP, then no SHAREMAP is required. If % a different drive on MYLAPTOP (e.g. X:) is mapped to \\ENGINEERING\cals, % then SHAREMAP would be {'W:','X:'}. If no suitable mapping exists on % MYLAPTOP, then SHAREMAP would be {'W:','\\ENGINEERING\cals'}. % % See also HGETREMOTEFILENAME. % Copyright 2004-2005 The MathWorks, Inc. % Initialize local = remote; % Return filename unchanged for empty share maps and empty filenames if isempty(shareMap) || isempty(remote) return end % Apply first matching entry in share map for i = 1:size(shareMap,1), key = shareMap{i,1}; if strncmpi(key, remote, length(key)) local = [shareMap{i,2}, remote(length(key)+1:end)]; return end end