📄 aft_saveas.m
字号:
function hfile = aft_SaveAs(hfile, newfile, dtitle)
% AnyFileType::SaveAs - method for any BVQXfile type
%
% FORMAT: obj.SaveAs([newfilename, dtitle]);
%
% Input fields:
%
% newfilename save-as filename, if not give, UI-based
% dtitle if given, override UI default title
%
% No output fields:
%
% obj BVQXfile object with newly set filename
% Version: v0.7b
% Build: 7082923
% Date: Aug-29 2007, 11:04 PM CEST
% Author: Jochen Weber, Brain Innovation, B.V., Maastricht, NL
% URL/Info: http://wiki.brainvoyager.com/BVQXtools
% check arguments
if nargin < 1 || ...
numel(hfile) ~= 1 || ...
~isBVQXfile(hfile, true)
error( ...
'BVQXfile:BadArguments', ...
'Invalid call to %s.', ...
mfilename ...
);
end
% get objects super-struct
sc = bvqxfile_getscont(hfile.L);
ndtitle = '';
if nargin > 1 && ...
ischar(newfile) && ...
(any(newfile == ' ') || ...
~any(newfile == '.'))
ndtitle = newfile(:)';
newfile = '';
end
if nargin < 2 || ...
~ischar(newfile) || ...
isempty(newfile)
if isempty(sc.F)
newfile = ['*.' sc.S.Extensions{1}];
else
[of{1:3}] = fileparts(sc.F);
newfile = ['*' of{3}];
end
end
if nargin < 3 || ...
~ischar(dtitle) || ...
isempty(dtitle)
if ~isempty(ndtitle)
dtitle = ndtitle;
else
dtitle = 1;
end
end
newfile = newfile(:)';
% make absolute name
[isabs{1:2}] = isabsolute(newfile);
newfile = isabs{2};
[fnparts{1:3}] = fileparts(newfile);
% check for "*.???"
if isempty(fnparts{2})
fnparts{2} = '*';
end
if isempty(fnparts{3}) || ...
strcmp(fnparts{3}, '.')
fnparts{3} = ['.' sc.S.Extensions{1}];
end
if any(fnparts{2} == '*')
extensions = BVQXfile(0, 'extensions');
file_formats = BVQXfile(0, 'formats');
filename = bvqxfile_requestfile(dtitle, ...
[fnparts{1} filesep fnparts{2} fnparts{3}], ...
extensions, file_formats, true);
if isempty(filename)
warning( ...
'BVQXfile:OperationCancelled', ...
'SaveAs dialog cancelled.' ...
);
return;
end
if iscell(filename)
filename = filename{1};
end
[isabs{1:2}] = isabsolute(filename);
newfile = isabs{2};
end
% what to do
try
switch (lower(sc.S.FFTYPE))
case {'bff'}
sc.C = bffio(newfile, sc.S, sc.C);
case {'tff'}
sc.C = tffio(newfile, sc.S, sc.C);
otherwise
error( ...
'BVQXfile:InvalidFileType', ...
'Type not recognized (?FF): %s.', ...
sc.S.FFTYPE ...
);
end
catch
error( ...
'BVQXfile:ErrorSavingFile', ...
'Error saving file %s: %s.', ...
newfile(:)', lasterr ...
);
end
% set new filename and maybe also content
sc.F = newfile;
bvqxfile_setscont(hfile.L, sc);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -