Mail Archives: djgpp/2000/09/13/18:49:04
Try this:
-- lfngsfn.c ----------------
/* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */
#include <libc/stubs.h>
#include <ctype.h>
#include <string.h>
#include <fcntl.h>
#include <dpmi.h>
#include <go32.h>
#include <sys/movedata.h>
char *
_lfn_get_short_fname (const char *long_fname, char *short_fname)
{
__dpmi_regs r;
unsigned long tbuf = __tb;
short_fname[0] = '\0';
if (_USE_LFN)
{
dosmemput (long_fname, strlen (long_fname) + 1, tbuf);
r.x.ax = 0x7160;
r.x.ds = tbuf >> 4;
r.x.si = 0;
r.x.es = r.x.ds;
r.x.di = 260;
r.h.cl = 0x01;
r.h.ch = 0x00;
__dpmi_int (0x21, &r);
if ((r.x.flags & 1) == 0 && r.x.ax != 0x7100)
{
dosmemget (tbuf + 260, 128, short_fname);
}
}
return short_fname;
}
#ifdef TEST
#include <stdio.h>
int main (int argc, char *argv[])
{
char sh[128];
if (argc > 1)
printf ("Long: %s\nShort: %s\n",
argv[1], _lfn_get_short_fname(argv[1], sh));
return 0;
}
#endif
- Raw text -