comparison +mpm/MatlabPathManager.m @ 25:e2c18217aee0

Fix some reference errors
author Jonatan Werpers <jonatan@werpers.com>
date Tue, 18 Sep 2018 12:56:22 +0200
parents fdad9fe450c5
children 05a8b30ee4a7
comparison
equal deleted inserted replaced
24:fdad9fe450c5 25:e2c18217aee0
23 % Load a given subpath into the state file and the matlab path and do savepath(), atomically 23 % Load a given subpath into the state file and the matlab path and do savepath(), atomically
24 function loadSubpath(obj, p) 24 function loadSubpath(obj, p)
25 state = mpm.PersistentState(obj.stateFilePath); 25 state = mpm.PersistentState(obj.stateFilePath);
26 26
27 addpath(p); 27 addpath(p);
28 state.added_paths(p) = true; 28 state.subpaths(p) = true;
29 29
30 state.saveState(); 30 state.saveState();
31 31
32 % TODO: Add savepath() 32 % TODO: Add savepath()
33 end 33 end
35 % Unload a given subpath from the state file and the matlab path and do savepath(), atomically 35 % Unload a given subpath from the state file and the matlab path and do savepath(), atomically
36 function unloadSubpath(obj, p) 36 function unloadSubpath(obj, p)
37 state = mpm.PersistentState(obj.stateFilePath); 37 state = mpm.PersistentState(obj.stateFilePath);
38 38
39 rmpath(p); 39 rmpath(p);
40 state.added_paths.remove(p); 40 state.subpaths.remove(p);
41 41
42 state.saveState(); 42 state.saveState();
43 43
44 % TODO: Add savepath() 44 % TODO: Add savepath()
45 end 45 end
54 sp = splitlines(strtrim(fstr)); 54 sp = splitlines(strtrim(fstr));
55 end 55 end
56 56
57 function s = loadedSubpaths(obj) 57 function s = loadedSubpaths(obj)
58 state = mpm.PersistentState(obj.stateFilePath); 58 state = mpm.PersistentState(obj.stateFilePath);
59 s = state.added_paths.keys(); 59 s = state.subpaths.keys();
60 % TODO: Make it respect order from the matlab path 60 % TODO: Make it respect order from the matlab path
61 end 61 end
62 62
63 function ps = matlabPath(obj) 63 function ps = matlabPath(obj)
64 ps = split(path(), pathsep); 64 ps = split(path(), pathsep);
127 % Unload all loaded subpaths. The matlab path should be returned to it's original state 127 % Unload all loaded subpaths. The matlab path should be returned to it's original state
128 function clear(obj) 128 function clear(obj)
129 sp = obj.loadedSubpaths(); 129 sp = obj.loadedSubpaths();
130 130
131 for i = 1:length(sp) 131 for i = 1:length(sp)
132 obj.unload(sp{i}); 132 obj.unloadSubpath(sp{i});
133 end 133 end
134 end 134 end
135 end 135 end
136 end 136 end
137 137
138 % TODO: Organize order of methods 138 % TODO: Organize order of methods
139 % TODO: Add flag for being persistent or not? (savepath or not)