view +mpm/PersistentState.m @ 35:3a28f6de13c2

Add function to test if a folder is project
author Jonatan Werpers <jonatan@werpers.com>
date Fri, 02 Nov 2018 13:10:57 +0100
parents 29da718b8e7f
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