delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/05/27/08:24:31

From: Christopher Heng <cyfhsite!chris>
Subject: Re: Library problems
To: wozzle!alane AT imageek DOT york DOT cuny DOT edu
Date: Fri, 27 May 1994 18:41:00 +0800 (SST)
Cc: djgpp <djgpp AT sun DOT soe DOT clarkson DOT edu>
Reply-To: chris%cyfhsite AT csar DOT csah DOT com

In a previous message, wozzle!alane AT imageek DOT york DOT cuny DOT edu wrote:
> 
> > > One way to make fstat() and stat() consistant would be to have fstat()
> > > call stat().  There must be some way to ask DOS for the pathname
> > > associated with the file pointer that fstat() gets, but I'm not a DOS
> > > expert so I don't know how to do that.
> > 
> > There's no easy documented way to do this. The undocumented way to do this
> > is to look up the file handle in the undocumented DOS system file table.
> > That'll yield only the filename (without path prefix). Getting a complete
> 
> Here's how to do it in real mode. Protected mode is left as an exercise
> for the reader :)

[ source deleted to save bandwidth ]

> 
> The interface was found in 'Undocumented DOS'. That is an
> indispensible book for the DOS hacker.
> 
> To see how this works, just type 'truename somefile' at any DOS prompt
> (where DOS is version 5.x or higher). It's built into command.com,
> although that isn't documented either <sigh>.

Hmm... I just tried it out. Unfortunately the function (and the
COMMAND.COM/4DOS commandline version) seems to only return the full path to
the current directory and drive regardless of whether the file exists or
not. For example, the command line version yields the following results:

	C:\TMP> truename config.sys
	C:\TMP\CONFIG.SYS

But there's no config.sys in the current C:\TMP directory (only the root
directory).

This will cause trouble if fstat() receives a file handle of a file opened
in a directory that is not the current directory. stat() will wind up
finding the stats of the wrong file (or even a non-existent file).

Perhaps fstat() should just return whatever info it can get under DOS on its
own and not try to rely on stat()?


Regards,

Chris Heng.

-- 
+-------------------+-----------------------------------+
| Christopher Heng  | Internet: chris%cyfhsite AT csah DOT com |
| Singapore         |           csah.com!cyfhsite!chris |
+-------------------+-----------------------------------+

- Raw text -


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