delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/11/01/19:04:53

Sender: nate AT cartsys DOT com
Message-ID: <363CF69D.DE8E8575@cartsys.com>
Date: Sun, 01 Nov 1998 16:02:37 -0800
From: Nate Eldredge <nate AT cartsys DOT com>
X-Mailer: Mozilla 4.05 [en] (X11; I; Linux 2.0.35 i486)
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Re: Listing long filenames
References: <Pine DOT SUN DOT 3 DOT 91 DOT 981027205143 DOT 8711P-100000 AT is>
Reply-To: djgpp AT delorie DOT com

Eli Zaretskii wrote:

> > Or otherwise, if I have a FILE *, how can I get the long filename for this
> > file ?
> 
> AFAIK, there is no way to do this on DOS/Windows.  Actually, I think
> Unix doesn't have such service either.

You could do it by finding the file handle with `fileno'.  From this you
can search some undocumented DOS data structures and find the drive and
starting cluster, and then read through all the directory entries on the
drive to find which one has that starting cluster.  It would be
extremely slow, unwieldly, and fragile.  Basically: Don't do it.

On Unix it's slightly easier, but the idea is the same.  You find the
file's inode, and search the whole filesystems for the file(s) with that
inode number.  It's complicated there because of hard links, whereby one
file with one inode may have multiple names.
-- 

Nate Eldredge
nate AT cartsys DOT com

- Raw text -


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