初版gui
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
function save_config_json(config, file_path)
|
||||
%SAVE_CONFIG_JSON Save a config struct to a JSON file.
|
||||
|
||||
arguments
|
||||
config (1,1) struct
|
||||
file_path (1,:) char
|
||||
end
|
||||
|
||||
folder_path = fileparts(file_path);
|
||||
if ~isempty(folder_path) && ~exist(folder_path, 'dir')
|
||||
mkdir(folder_path);
|
||||
end
|
||||
|
||||
json_text = jsonencode(config, PrettyPrint=true);
|
||||
fid = fopen(file_path, 'w');
|
||||
if fid == -1
|
||||
error('save_config_json:FileOpenFailed', 'Cannot open file: %s', file_path);
|
||||
end
|
||||
|
||||
cleanup_obj = onCleanup(@() fclose(fid));
|
||||
fprintf(fid, '%s', json_text);
|
||||
Reference in New Issue
Block a user