This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Problem with dereference option on Windows LNKs (shortcuts)


From: Igor Pechtchanski On: 7/12/03 6:05 PM

On Sat, 12 Jul 2003, Dan Mellem wrote:

>> Hi,
>>
>> I have a folder that's full of shortcuts to other files (called
>> 'shortcuts'). I'd like to interact with the original files instead of
>> the shortcut (.lnk) files. Basically, if the shortcut is created from
>> within CYGWIN (ln -s [whether CYGWIN=nowinsymlinks or winsymlinks]),
the
>> command:
>>
>> $ cp -LR shortcuts/ shortcuts2/
>>
>> will copy the original files (dereferencing the symbolic links).
>> However, if the shortcut was created in MS-Windows, all I get is a
copy
>> of the shortcuts. The only difference between the MS LNKs and the
[...]
>Cygwin symlinks are a bit more than read-only shortcut (.lnk) files.
>They have a special format, and they also have something in their
>"Comment" field (that you can check via shortcut properties).  In short,
>you cannot easily create a Cygwin symlink from outside Cygwin.  For
>exact details, see the source of the symlink() function in
>winsup/cygwin/path.cc.
>	Igor

Thanks, Igor. I thought that since it created MS-Windows-compatable .LNKs,
it also read regular .LNKs and used them as symlinks.

I took a look at the source
(http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/winsup/cygwin/path.cc?cvsr
oot=src) but didn't find anything specific that said that they aren't
treated as symlinks. I'm not familiar with the source but there was a
section:

      /* Windows shortcuts are treated as symlinks. */
      if (suffix.lnk_match ())
	sym_check = 1;
[...]
      if (sym_check > 0 && opt & PC_CHECK_EA &&
	  (res = get_symlink_ea (suffix.path, contents, sizeof (contents)))
> 0)
	{
	  pflags = PATH_SYMLINK;
	  if (sym_check == 1)
	    pflags |= PATH_LNK;
	  debug_printf ("Got symlink from EA: %s", contents);
	  break;
	}

      /* Open the file.  */


I don't know what this all means but it implies to me that it will at least
attempt to read the shortcut file. Is it possible to parse through regular
shortcut files too?

Thanks again.

-Dan

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]