release 1.0
This commit is contained in:
47
McuLib/install_my_library.m
Normal file
47
McuLib/install_my_library.m
Normal file
@@ -0,0 +1,47 @@
|
||||
% install_my_library.m
|
||||
function install_my_library()
|
||||
libDir = fileparts(mfilename('fullpath'));
|
||||
|
||||
% 1. Добавляем библиотеку и m-файлы в путь
|
||||
addpath(fullfile(libDir, 'lib'));
|
||||
addpath(fullfile(libDir, 'm'));
|
||||
savepath;
|
||||
|
||||
% 2. Диалог выбора папки для копирования шаблонов
|
||||
defaultTargetDir = pwd;
|
||||
answer = questdlg(['Выберите папку для копирования шаблонов кода. ', ...
|
||||
'По умолчанию текущая папка: ' defaultTargetDir], ...
|
||||
'Выбор папки', ...
|
||||
'Текущая папка', 'Выбрать другую', 'Текущая папка');
|
||||
|
||||
switch answer
|
||||
case 'Выбрать другую'
|
||||
targetDir = uigetdir(defaultTargetDir, 'Выберите папку для шаблонов');
|
||||
if isequal(targetDir,0)
|
||||
disp('Копирование шаблонов отменено пользователем.');
|
||||
targetDir = '';
|
||||
end
|
||||
case 'Текущая папка'
|
||||
targetDir = defaultTargetDir;
|
||||
otherwise
|
||||
targetDir = defaultTargetDir;
|
||||
end
|
||||
|
||||
if ~isempty(targetDir)
|
||||
templatesDir = fullfile(libDir, 'templates');
|
||||
templateFiles = dir(fullfile(templatesDir, '*.*'));
|
||||
for k = 1:numel(templateFiles)
|
||||
if ~templateFiles(k).isdir
|
||||
copyfile(fullfile(templatesDir, templateFiles(k).name), ...
|
||||
fullfile(targetDir, templateFiles(k).name));
|
||||
end
|
||||
end
|
||||
fprintf('Шаблоны кода скопированы в папку:\n%s\n', targetDir);
|
||||
end
|
||||
|
||||
% 3. Обновляем Library Browser
|
||||
rehash;
|
||||
sl_refresh_customizations;
|
||||
|
||||
disp('Библиотека успешно установлена и добавлена в Library Browser.');
|
||||
end
|
||||
Reference in New Issue
Block a user