diff +mpm/MatlabPathManager.m @ 23:0b4be0d4e207

Use new class for state management
author Jonatan Werpers <jonatan@werpers.com>
date Tue, 18 Sep 2018 11:52:14 +0200
parents 2e29cca20d8a
children fdad9fe450c5
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