function dir_path = get_data_dir()
- if (isfile('.last_path'))
- file_id = fopen('.last_path', 'r');
- last_path = char(fread(file_id))';
- fclose(file_id);
- dir_path = uigetdir(last_path, 'Select the data folder');
- if ispc
- fileattrib('.last_path', '-h');
- end
- else
- dir_path = uigetdir(pwd(), 'Select the data folder');
- end
+ dir_path = uigetdir(get_last_path(), 'Select the data folder');
if dir_path == 0
return
end
-
- file_id = fopen('.last_path', 'w');
- fprintf(file_id, "%s", dir_path);
- fclose(file_id);
- if ispc
- fileattrib('.last_path', '+h');
- end
+ update_last_path(dir_path)
end
--- /dev/null
+function last_path = get_last_path()
+ if (isfile('.last_path'))
+ file_id = fopen('.last_path', 'r');
+ last_path = char(fread(file_id))';
+ fclose(file_id);
+ if ispc
+ fileattrib('.last_path', '-h');
+ end
+ else
+ last_path = pwd()
+ end
+end
--- /dev/null
+function update_last_path(last_path)
+ file_id = fopen('.last_path', 'w');
+ fprintf(file_id, "%s", last_path);
+ fclose(file_id);
+ if ispc
+ fileattrib('.last_path', '+h');
+ end
+end