Mercurial > repos > public > matlab_path_manager
changeset 23:0b4be0d4e207
Use new class for state management
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Tue, 18 Sep 2018 11:52:14 +0200 |
parents | 29da718b8e7f |
children | fdad9fe450c5 |
files | +mpm/MatlabPathManager.m +mpm/init_state.m +mpm/load_state.m +mpm/save_state.m |
diffstat | 4 files changed, 8 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/+mpm/MatlabPathManager.m Tue Sep 18 11:41:39 2018 +0200 +++ b/+mpm/MatlabPathManager.m Tue Sep 18 11:52:14 2018 +0200 @@ -1,7 +1,7 @@ classdef MatlabPathManager properties projectFileName = '.subpaths'; - stateFileName = ''; + stateFileName = 'state'; end methods @@ -14,26 +14,26 @@ % Load a given subpath into the state file and the matlab path and do savepath(), atomically function loadSubpath(obj, p) - state = mpm.load_state(); + state = mpm.PersistentState(obj.stateFilePath); addpath(p); state.added_paths(p) = true; - mpm.save_state(state); + state.saveState(); - % TODO: Make atomic + add savepath() + % TODO: Add savepath() end % Unload a given subpath from the state file and the matlab path and do savepath(), atomically function unloadSubpath(obj, p) - state = mpm.load_state(); + state = mpm.PersistentState(obj.stateFilePath); rmpath(p); state.added_paths.remove(p); - mpm.save_state(state); + state.saveState(); - % TODO: Make atomic + add savepath() + % TODO: Add savepath() end % Read project file in a folder and return cell array of all subpaths @@ -47,7 +47,7 @@ end function s = loadedSubpaths(obj) - state = mpm.load_state(); + state = mpm.PersistentState(obj.stateFilePath); s = state.added_paths.keys(); % TODO: Make it respect order from the matlab path end @@ -126,5 +126,3 @@ end end end - -% TODO: get rid of mpm.load_state and mpm.save_state
--- a/+mpm/init_state.m Tue Sep 18 11:41:39 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -function init_state() - s = struct(); - s.added_paths = containers.Map(); - mpm.save_state(s); -end