Mercurial > repos > public > matlab_path_manager
view +mpm/PersistentState.m @ 22:29da718b8e7f
Add class for managing state file
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Tue, 18 Sep 2018 11:41:39 +0200 |
parents | |
children | 16d56bf04117 |
line wrap: on
line source
classdef PersistentState < handle properties filepath subpaths end methods function obj = PersistentState(filepath) obj.filepath = filepath; try % Read state from file s = load(filepath); obj.subpaths = s.subpaths; catch % If reading the file failed, create an empty state obj.subpaths = containers.Map(); end end function s = saveState(obj) s = struct(); s.subpaths = obj.subpaths; save(obj.filepath, '-struct', 's'); end end end