Mail Archives: djgpp/1997/10/05/11:41:06
On Sat, 4 Oct 1997, Jeff Taylor wrote:
> Is there a long to short filename converter program available? Id like
> to write a bash script that takes long file names and quietly converts
> them to short (8.3) filenames before passing them to a older program
> without LFN support.
You didn't explain enough about why such conversion is needed, so I
will have to guess.
Old DOS programs issue DOS calls when accessing files, and those calls
automatically truncate the long names. So for file names whose 8.3
alias is just a truncation of the long name, you shouldn't worry at
all. If you set the NameNumericTail property in the registry to 0
(the DJGPP FAQ list explains how to do that, in section 8.2), then all
long names are just truncated, and you should have no problems with
old programs.
If you haven't set NameNumericTail to 0, and you need to convert the
long name to its precise short alias (such as "Program Files" ->
PROGRA~1), you will have to use a special function of Interrupt 21h
(write a short program that gets a long name and prints its short
variety). The following excerpt is from Ralf Brown's Interrupt List
(note that this call will fail for non-existing files):
--------D-217160CL01-------------------------
INT 21 - Windows95 - LONG FILENAME - GET SHORT (8.3) FILENAME FOR FILE
AX = 7160h
CL = 01h
CH = SUBST expansion flag
00h return a path containing true path for a SUBSTed drive letter
80h return a path containing the SUBSTed drive letter
DS:SI -> ASCIZ long filename or path
ES:DI -> 67-byte buffer for short filename
Return: CF set on error
AX = error code
02h invalid component in directory path or drive letter only
03h malformed path or invalid drive letter
ES:DI buffer unchanged
CF clear if successful
ES:DI buffer filled with equivalent short filename (full path,
even if relative path given, and all uppercase)
Note: this call returns the short name for any long-filename portions of
the provided pathname or filename
SeeAlso: AH=60h,AX=7160h/CL=00h,AX=7160h/CL=02h
- Raw text -