On 17/03/09 10:59, Yakov wrote:
>
> Thanks for the resolve() lead.
>
> For the record, It turns out that resolve() resolves symlinks but does
> not make them absolute.
> For example if if path1== "/home/joe" and path2 == "." and current dir
> is "/home/joe",
> expression (resolve(path1) == resolve(path2)) is false.
>
> The following does the trick for me:
>
> func! ResolveAndMakeAbsolute(path)
> let r = expand(a:path)
> return r[0] == '/' ? resolve(r) : getcwd() . "/" . r
> endfun
>
>
> (which breaks on Windows but that is another story).
>
> On Mar 17, 5:17 am, John Little<[email protected]> wrote:
>> :h resolve()
>>
>> Regards, John
On any system, you can resolve symlinks and get the absolute path by
fnamemodify(resolve(filename), ':p')
which will also make sure there is a / at the end if it is a directory.
However, on systems like W-NT and Unix where hardlinks exist, i.e. where
it is possible to have, in a valid way, two (or more) directory entries
pointing to the same data without one of them being a shortcut (a
symlink) to the other, you'll still get different values if you use
different hardlinks to the same data as the filename. To resolve
hardlink synonyms, you'd need a function giving both the partition
(maybe E: on Windows, /dev/sda3 on Linux, etc.) and also the FAT cluster
number or the inode number, as a function of the full pathname (of the
file or folder) after resolving all softlinks or shortcuts like above. I
don't know whether Vim possesses such a function (or couple of functions).
Best regards,
Tony.
--
An elephant is a mouse with an operating system.
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---