+sub relativise
+{
+ my($self, $path, $name, $mountpoint, $id3fs_path)=@_;
+ $id3fs_path=~s/(.*)\/.*/$1/;
+ my $rpath="$self->{absbase}/$path";
+ my $vpath="$mountpoint/$id3fs_path";
+ my @path=split(/\//,$rpath);
+ my @rel=split(/\//,$vpath);
+ #absolute paths have empty first element due to leading /
+ shift(@path) if($path[0] eq "");
+ shift(@rel) if($rel[0] eq "");
+ if($path[0] ne $rel[0])
+ {
+ #no path in common, return absolute
+ print "FAIL: NO PATHS IN COMMON\n";
+ return $name;
+ }
+ # f: /home/foo/bar/baz.mp3
+ # r: /home/ianb/music/albums
+ while(@path && @rel && ($path[0] eq $rel[0]))
+ {
+ shift(@path);
+ shift(@rel);
+ print "POP ";
+ }
+ print "\n";
+ my $upcount=scalar(@rel);
+ my $result="../" x $upcount;
+ $result .= join("/",@path);
+ $result .= "/$name";
+ return $result;
+}
+