Subject: Re: [nmr_sparky] changing pathnames in save files.
From: eiso
Date: Oct 29, 2007

Previous: 435 Next: 437


Hi Tom,

thanks, Ill see what happens without links and/or ..
fwiw, I dont consider sparky clunky at all, although
its a pity that its not developed anymore. Its
amazing how usable it remains after all these years.
Sparky was a liberating experience, after messing around
with some other programs.

Eiso

Tom Goddard wrote:
Hi Eiso,

Sparky tries to use relative paths so if you move a directory
containing project/save/spectrum files then everything continues to
work. Heres the directory organization this was intended to work with:

some-dir/
spectra/
save/
project/

I always get title-cased dirs (Save/Project etc).
does this matter?


Then the save files will contain paths to spectra like
../spectra/hnca.ucsf and the project files will contain paths to peak
(save) files like ../save/hnca.save. So if you put your
processed_data directory (what I called spectra -- names dont matter)
in the same directory as Save instead of one level up it would work
smoothly. Except that it expands out symbolic links before deciding if
it can form relative paths. So if you have your spectra in some other
location with symbolic links to them they will be replaced by absolute
paths. This is because .. does not play well with symbolic links.
There is no provision to turn of the relative path modifications in
Sparky -- youd have to recompile with a few edits to format.cc.

Where does Sparky show peak numbers? The numbering is only internal
to peak files. Unfortunate since I realize it would be useful to have
such a permanent peak identifier. Those numbers in the peak files are
only created when the peak file (save file) is written -- it just
counts from 1. There is no id number associated with a peak.

My apologies for the clunkiness of the program. It is ashame there is
noone to develop it and fix these problems.

Below is the format.cc comment about relative paths that may provide
some additional info about the relative paths saved in files.

Tom

//
----------------------------------------------------------------------------
// If path is base-path/xxx/file and the directory is base-path/yyy then
// return the relative path ../xxx/file. Otherwise return path.
// Symbolic links are expanded out before the comparisons are made because
// the file reached by the relative ../xxx/file path depends on how the
// directory path is written (ie /symlink/../xxx/file is different from
// /somewhere/else/../xxx/file even when /symlink points to /somewhere/else)
//
// This routine is used so that your Sparky directory containing Save file,
// Project file, and spectra subdirectories can be moved without fixing
// absolute paths in the files.
//
static Stringy relative_path(const Stringy , const Stringy )
{
Stringy p = resolve_links(path);
Stringy d = resolve_links(directory);
Stringy s = file_directory(d);
if (s.length() p.length() && s == p.substring(0, s.length()))
return ../ + p.substring(s.length() + 1);
return path;
}