mtools: long names

1 
1 2.4 VFAT-style long file names
1 ==============================
1 
1 This version of mtools supports VFAT style long filenames. If a Unix
1 filename is too long to fit in a short DOS name, it is stored as a VFAT
1 long name, and a companion short name is generated. This short name is
1 what you see when you examine the disk with a pre-7.0 version of DOS.
1 The following table shows some examples of short names:
1 
1      Long name       MS-DOS name     Reason for the change
1      ---------       ----------      ---------------------
1      thisisatest     THISIS~1        filename too long
1      alain.knaff     ALAIN~1.KNA     extension too long
1      prn.txt         PRN~1.TXT       PRN is a device name
1      .abc            ABC~1           null filename
1      hot+cold        HOT_CO~1        illegal character
1 
1    As you see, the following transformations happen to derive a short
1 name:
1    * Illegal characters are replaced by underscores. The illegal
1      characters are `;+=[]',\"*\\<>/?:|'.
1 
1    * Extra dots, which cannot be interpreted as a main name/extension
1      separator are removed
1 
1    * A `~'N number is generated,
1 
1    * The name is shortened so as to fit in the 8+3 limitation
1 
1    The initial Unix-style file name (whether long or short) is also
1 called the "primary" name, and the derived short name is also called the
1 "secondary" name.
1 
1    Example:
1       mcopy /etc/motd a:Reallylongname
1     Mtools creates a VFAT entry for Reallylongname, and uses REALLYLO as
1 a short name. Reallylongname is the primary name, and REALLYLO is the
1 secondary name.
1       mcopy /etc/motd a:motd
1     Motd fits into the DOS filename limits. Mtools doesn't need to
1 derivate another name. Motd is the primary name, and there is no
1 secondary name.
1 
1    In a nutshell: The primary name is the long name, if one exists, or
1 the short name if there is no long name.
1 
1    Although VFAT is much more flexible than FAT, there are still names
1 that are not acceptable, even in VFAT. There are still some illegal
1 characters left (`\"*\\<>/?:|'), and device names are still reserved.
1 
1      Unix name       Long name       Reason for the change
1      ---------       ----------      ---------------------
1      prn             prn-1           PRN is a device name
1      ab:c            ab_c-1          illegal character
1 
1    As you see, the following transformations happen if a long name is
1 illegal:
1    * Illegal characters are replaces by underscores,
1 
1    * A `-'N number is generated,
1