delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2005/01/14/19:00:57

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: "Mike C" <My DOT address AT end DOT of DOT post>
Newsgroups: comp.os.msdos.djgpp
References: <oGSFd.353$N25 DOT 335 AT newsfe3-gui DOT ntli DOT net> <jn2gu0poddqg34n9cp2mr4dq4u29323lg5 AT 4ax DOT com>
Subject: Re: intdos question
Lines: 115
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
Message-ID: <WTYFd.335$rw1.77@newsfe3-win.ntli.net>
Date: Fri, 14 Jan 2005 23:49:10 GMT
NNTP-Posting-Host: 62.253.115.224
X-Complaints-To: http://www.ntlworld.com/netreport
X-Trace: newsfe3-win.ntli.net 1105746550 62.253.115.224 (Fri, 14 Jan 2005 23:49:10 GMT)
NNTP-Posting-Date: Fri, 14 Jan 2005 23:49:10 GMT
Organization: ntl Cablemodem News Service
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Brian, you're a star!  I haven't actually tried it yet, (it's almost
midnight in the UK) but I'll give it a go during the weekend.

What you have written certainly looks promising!

My sincere thanks,

Mike Collins.
------------------------

"Brian Inglis" <Brian DOT Inglis AT SystematicSW DOT Invalid> wrote in message
news:jn2gu0poddqg34n9cp2mr4dq4u29323lg5 AT 4ax DOT com...
> On Fri, 14 Jan 2005 16:45:08 GMT in comp.os.msdos.djgpp, "Mike C"
> <My DOT address AT end DOT of DOT post> wrote:
>
> >Can somebody please point me in the right direction?
> >
> >I have written a parser, which parses a source file and creates a
> >destination file.
> >
> >To operate the program, I select the source file in Windows explorer and
> >drag it onto a shortcut to my program. This leaves the path to the source
> >file in argv[1].  My problem is that the string that I find in argv[1] is
> >all in DOS 8.3 format.  I would like to name the destination file the
same
> >as the source file, with a long filename, changing only the extension.
> >
> >As I know the short filename, I thought of using findfirst() and
findnext()
> >to locate the long filenames, then generate the short filename for each
one
> >and compare it to the known short filename. Simple in concept!
> >
> >I have been looking at Ralph Brown's interrupt list, int21, AX=7160.
> >
> >It says :
> >
> >AX = 7160h
> >CL = 00h
> >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 filename or path (either long name or short name)
> >ES:DI -> 261-byte buffer for canonicalized name
> >
> >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 fully qualified name
> >AX destroyed
> >
> >... so I guess I need to load DS:SI with a pointer to my long filename
> >buffer, and it will return a pointer to the short filename in ES:DI, but
> >that's where I get stuck.
>
> You want to go the other way from short to long, don't you?
> You use subfunction 2 to get the long name from the short name.
>
> >I'm not very familiar with the Intel registers.  How do I get my pointer
> >into DS:SI?  If I'm not mistaken, SI is an index register that gets added
to
> >DS?  How do I work it all out?
> >
> >With thanks to anybody who spends their precious time on this,
>
> You need to use the go32 transfer buffer in low memory.
> Try this:
>
> #include <dpmi.h>
> #include <go32.h>
>
> /* get lfn */
> static char *
> get_lfn( char *long_name, const char *short_name, int long_len)
> {
>       __dpmi_regs r;
>
>       dosmemput( short_name, strlen(short_name)+1, __tb);
>       r.x.ax = 0x7160;          /* Truename */
>       r.x.cx = 2;                       /* Get long name */
>       r.x.ds = r.x.es = __tb / 16;
>       r.x.si = r.x.di = __tb & 15;
>       __dpmi_int(0x21, &r);
>
>       if (r.x.flags & 1 || r.x.ax == 0x7100)
>       /* Shouldn't happen: LFN *is* supported and file *does* exist.
> */
>         return NULL;
>
>       dosmemget(__tb, long_len, long_name);
>       return long_name;
> }
>
> and wrap the call with a test, just to be safe:
>
> #include <fcntl.h>
> #include <string.h>
>
> ...
>
>   if (!_use_lfn( short_name )
>         || !get_lfn( long_name, short_name, long_len))
>     strcpy( long_name, short_name);
>
> -- 
> Thanks. Take care, Brian Inglis Calgary, Alberta, Canada
>
> Brian DOT Inglis AT CSi DOT com (Brian[dot]Inglis{at}SystematicSW[dot]ab[dot]ca)
>     fake address use address above to reply



- Raw text -


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