Use of relative filenames creates problems in Windows in pathological cases
I have a very long pathname for one mod-file. When using a purely relative filename in check_posterior_analysis_data.m
like
name_of_the_last_post_data_file = ...
[ './' M_.dname ...
'/metropolis/' ...
M_.fname '_' ...
generic_post_data_file_name ...
int2str(number_of_the_last_post_data_file) ...
'.mat' ];
pdfdate = get_date_of_a_file(name_of_the_last_post_data_file);
I get an error that the file cannot be found, although it is there. Matlab's help says
If you get unexpected results when working with long path names, use absolute instead >of relative path names.
Hence, I added a pwd
instead of the dot to the path-name and the above code runs without problems. Is there a particular reason for using relative names?
Transitioning to absolute names using pwd
seems more robust and is recommended by Matlab. Thus, I would suggest to use absolute path names in the future and adding a pwd
to existing relative path names. Such a change could be done gradually without disrupting any functionality and coexistence of old and new code is also no problem.
However, I can't speak for Linux/Mac and Octave. What do you think?