www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/09/13/18:49:04

Message-ID: <39BFA94F.A034873D@teleline.es>
Date: Wed, 13 Sep 2000 18:20:31 +0200
From: Mariano Alvarez Fernandez <malfer AT teleline DOT es>
X-Mailer: Mozilla 4.5 [es] (Win95; I)
X-Accept-Language: es
MIME-Version: 1.0
To: djgpp <djgpp AT delorie DOT com>, seb AT techno-matic DOT dk
Subject: Re: How do I get the msdos "long" (x~1.y) filename when I know the real
windows long
Reply-To: djgpp AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019