-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstartup_ebsdam.m
104 lines (82 loc) · 2.53 KB
/
startup_ebsdam.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
function startup_ebsdam(varargin)
% Initialize EBSD Analysis Module.
% It sets preferences and search paths. It's dynamic way of setup.
%
% Syntax
% startup_ebsdam(varargin)
%
% Input
% 'uninstall' - uninstall module
%
% History
% 27.03.13 Ask 'output_dir' before 'cache_dir'.
% 05.04.13 Increase minor version.
% 12.04.13 Dynamic setup: now this fucntion running on MATLAB starting
% from 'startup'.
% For unsinstall call 'startup_ebsdam('uninstall')'.
% New additional directories will be added after restart, only
% one root access needed.
mpath = path;
% Script directory
basepath = fileparts(mfilename('fullpath'));
% Uninstallation
if (nargin > 0 && any(strcmp('uninstall',varargin)))
disp('Uninstall EBSDAM')
if ispref('ebsdam'), rmpref('ebsdam'); end;
mm = regexp(mpath, '[^;]+', 'match');
n = length(basepath);
ind = cellfun(@(x) strncmp(x,basepath,n), mm);
cellfun(@(x) rmpath(x), mm(ind));
return;
end
% Read version from version file
try
fid = fopen('version.txt','r');
EBSDAMversion = fgetl(fid);
fclose(fid);
catch
EBSDAMversion = 'EBSDAM';
end
disp([upper('Startup ') EBSDAMversion]);
% Check instalation
if install_ebsdam(mpath,basepath), return; end;
% Additional dirs
dirs = {{'func'}, {'func' 'dev'}, {'func' 'recon'}, {'func' 'misc'}, {'func' 'OR'}, {'func' 'third_party'},...
{'load'}, {'tcode'}, {'ui'}};
dirs = cellfun(@(p) fullfile(basepath,p{:}), dirs, 'uniformoutput', false);
addpath(dirs{:},'-end');
%rmpref('ebsdam');
setpref('ebsdam', 'version', EBSDAMversion);
setpref('ebsdam', 'src_dir', basepath);
% Setup working direstories
if exist('EBSDAM_settings.m','file')
EBSDAM_settings;
else
disp('Cann''t find ''EBSDAM_settings.m'' file. Run ''setupWorkDirs''.');
end
end
function err = install_ebsdam( mpath, basepath )
% Install EBSD Analysis Module to MATLAB.
% Install EBSDAM by added base dir to MATLAB search path. At start MATLAB
% run 'startup' from search path. To use more then one module write
% general 'startup' and cal 'startup_ebsdam' in it.
err = 0;
% Find basepath is in search path
if strfind(mpath,basepath), return; end
% Find old installation in another dir
if strfind(mpath,'ebsdam')
disp('Find another EBSDAM dir in search path. Please delete previous version.')
err = 1;
return;
end
% Remove old prefs
if ispref('ebsdam'), rmpref('ebsdam'); end
% Installation
disp('Installing EBSD Analysis Module: ');
addpath(basepath,'-end');
if ~savepath
disp('Done');
else
disp('!!! Failed !!!');
end
end