Dateiverknüpfungen von Win nach Linux portieren

Software besorgen und anwenden
Post Reply
Message
Author
Guido Z.

Dateiverknüpfungen von Win nach Linux portieren

#1 Post by Guido Z. »

Hallo,

gerade haben wir unsere Redaktion von Windows nach Linux umgebaut. Alles ging auch wunderbar und ohne größere Probleme.

Doch die Tücke ist immer im Detail. Der gesamte Datenbestand wurde von dem Windows Dateisystem in Linux-System übernommen. In dem Widnowssystem gab es viele Verknüfungen zu anderen Datein ( xyz.ink ). Wie kann man diese Verknüpfungen nun auch unter Linux nutzen bzw. umwandeln?

Danke im Voraus

Gudio

User avatar
heinrich
Posts: 219
Joined: 22. Sep 1999 11:22
Location: N49.137 E8.544

#2 Post by heinrich »

Erst einmal:
LNK shortcut files
The format of these is unpublished. Wotsit's file format information http://www.wotsit.org/ and the Perl Win32::Shortcut module merely refer to the Win32 IShellLink API, which is useless if you're trying to manipulate LNK files on a non-Windows platform.

Empirical evidence suggests that LNK files consist of variable size blocks of data, each starting with a two-byte little-endian length:

The first block seems to contain flags. Byte 0x0018 is 0x10 if this is a shortcut to a folder, while the top nibble of byte 0x0014 is 0x10 if a 'start in' directory is specified. Byte 0x0014 is 0x01 and byte 0x0018 is 0x00 if this is a special network shortcut (to 'My computer', to the network neighbourhood, and so on). The second block itself consists of variable sized records, each starting with a record length and contains the actual shortcut name, broken down in various ways. The third block, if present, may contain 16-bit Unicode text (if the link was created under NT?).

Having said all that, the easiest way to find what the shortcut points to is to ignore the block structure and essentially to do a Unix 'strings' command on the whole file. The only caveat is that while all the strings are null-terminated, the start of the string is not delimited so may be prefixed by a couple of random characters. Pick the last (or last but one, if the shortcut has a 'start in' directory) string that looks like an absolute path, either starting with '\\' or a drive letter and colon. If it's a network path starting with '\\' the host and share name and the directory/file within that share are stored as two components separated by a single nul character, so need to be concatenated with a '\' separator. This is the target of the shortcut. Finally, the last string in the file is the starting directory, if one is specified.
Falls du es doch versuchen solltest, dann hilft dir sicher auch die Wotsit Webseite: http://www.wotsit.org/search.asp?s=LNK
It just works.

Post Reply