-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathsaveR2.m
More file actions
40 lines (31 loc) · 1.08 KB
/
saveR2.m
File metadata and controls
40 lines (31 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
function saveR2(dirName,problem,results,controls)
% Saves the current project in RasCAL2 format...
arguments
dirName {mustBeText}
problem {mustBeA(problem, 'projectClass')}
results
controls {mustBeA(controls, 'controlsClass')}
end
% Check whether the save directory exists, create it if necessary
if exist(dirName,'dir') ~= 7
mkdir(dirName);
end
currentDir = pwd; % Save the current directory name
% Do some custom file housekeeping. We need to copy these to our new
% folder if there are any..
filesTable = problem.customFile.varTable;
for i = size(filesTable,1)
thisFile = fullfile(filesTable{i,'Path'},filesTable{i,'Filename'});
copyfile(thisFile,dirName)
% Change the paths of our custom files in projectClass to point to our
% new files..
problem.setCustomFile(i,'path',fullfile(currentDir,dirName));
end
% Go to our new directory and export the jsons...
cd(dirName);
projectToJson(problem,'project.json');
resultsToJson(results,'results.json');
controlsToJson(controls,'controls.json');
% Go back to our original dir and we are done...
cd(currentDir);
end