[comp.os.os2] DosFindFirst with HPFS names ?

ARMENGAU@FRECP12.BITNET (Joel Armengaud) (04/09/90)

How can I get the long file names on an HPFS partition ?
When I use DosFindFirst, increasing the FILEFINDBUF structure, it doesn't
work...  Do I have to put a non-zero value in the last argument,
documented as "Reserved" ?
        -Joel Armengaud

dbaum@camilla.East.Sun.COM (Derek Baum - Sun PC Distributed Systems) (04/10/90)

In article <90098.181854ARMENGAU@FRECP12.BITNET> ARMENGAU@FRECP12.BITNET (Joel Armengaud) writes:
>How can I get the long file names on an HPFS partition ?
>When I use DosFindFirst, increasing the FILEFINDBUF structure, it doesn't
>work...  Do I have to put a non-zero value in the last argument,
>documented as "Reserved" ?

You should not need to increase sizeof FILEFINDBUF.achName, it was increased
to CCHMAXPATHCOMP (255) with OS|2 1.2. Check you are using new 1.2 headers.

The documentation states that the maximum filename that can be retrieved
by DosFindFirst() is 13 bytes (8.3 + null). To retrieve a longer filename,
you must use DosFindFirst2().

This is not entirely true. Long filenames can be retrieved using DosFindFirst()
if the LONGNAMES bit is set in the executable header. This can be done with
the SDK 1.2 markexe utility: markexe lfns program.exe.

DosFindFirst2() works regardless of the setting of LONGNAMES bit, and in
addition allows the retrieval of selected extended attributes. However,
its use will prevent your application from running on OS| 1.1... unless
you selectively run-time dynamic link to DosFindFirst2() -- UGGH!
DosFindFirst2 was unnecessary, it *should* have used the reserved parameter
in DosFindFirst()! OS|2 2.0 fixes this bug :-)

--
Derek Baum consulting at:
Sun Microsystems    Internet: dbaum@East.Sun.COM
(508)671-0456       UUCP: ...!sun!suneast!dbaum

phg@cs.brown.edu (Peter H. Golde) (04/10/90)

In article <90098.181854ARMENGAU@FRECP12.BITNET> ARMENGAU@FRECP12.BITNET (Joel Armengaud) writes:
>How can I get the long file names on an HPFS partition ?
>When I use DosFindFirst, increasing the FILEFINDBUF structure, it doesn't
>work...  Do I have to put a non-zero value in the last argument,
>documented as "Reserved" ?

You have to set a special NEWFILES bit in the .EXE to gain access
to the long file names.  This can be done at link time with the
word NEWFILES after the name of the file and app types in
the NAME statement.  Or you can modify it after the fact;
Microsoft C 6.0 had an EXEMOD utility to do it, and the 1.2 toolkit
probably has a way to do it as well, though I don't know for sure.
Should be real easy to cobble one together yourself, too.

This seems like a stupid way to do it, but I guess it was done so
that stupid 1.1 programs which do DosFindFirsts won't crash when
run on an HPFS system.  Pity we have to put up with goofiness
like this, but better than killing old programs (even if they were
written wrong).  

--Peter Golde

t-willb@microsoft.UUCP (Wiliam BONNER) (04/12/90)

In article <90098.181854ARMENGAU@FRECP12.BITNET>, ARMENGAU@FRECP12.BITNET (Joel Armengaud) writes:
> How can I get the long file names on an HPFS partition ?
> When I use DosFindFirst, increasing the FILEFINDBUF structure, it doesn't
> work...  Do I have to put a non-zero value in the last argument,
> documented as "Reserved" ?

The way to get long filenames in OS/2 1.2 is to use the DosFindFirst2 
function instead of the DosFindFirst function.

Actually, I just realized that my last program to use the findfirst/findnext
functions worked fine with long filenames, and I used the older version.

I am using the 1.2 SDK and C 6.0 though.  

Wim.

smeans@microsoft.UUCP (Scott MEANS) (04/12/90)

In article <90098.181854ARMENGAU@FRECP12.BITNET> ARMENGAU@FRECP12.BITNET (Joel Armengaud) writes:
>How can I get the long file names on an HPFS partition ?

The way to notify the system that your app can cope with long filenames is 
rather obscure, but what you need to do is add the NEWFILES keyword to your
.def file.  Here is a sample def file:

NAME LONGAPP NEWFILES
DESCRIPTION 'App that deals with HPFS file names'

Basically this just sets a bit in your exehdr, and if you have the markexe
utility you can set this bit on any exe you want with the command:

markexe lfns appname.exe

(Caution: if the app doesn't really deal with long filenames this will 
probably cause some undesired effects, but it usually doesn't hurt too much
to experiment.)
-- 
     /\/\
    //\/\\
    \>  </
   S/    \eans

ballard@cheddar.cc.ubc.ca (Alan Ballard) (04/12/90)

In article <54035@microsoft.UUCP> t-willb@microsoft.UUCP (Wiliam BONNER) writes:
>The way to get long filenames in OS/2 1.2 is to use the DosFindFirst2 
>function instead of the DosFindFirst function.

The important thing isn't whether you use DosFindFirst or DosFindFirst2, 
but whether the calling program is marked as "HPFS-aware".  There is a 
new flag in the EXE file header that indicates whether the program is 
prepared to deal with long file names.  This flag can ben set with 
a grungy little program that patches the header (several are floating
around on various systems...), or with the new toolkit, by a specification
in the DEF file. 
 



Alan Ballard                   | Internet: Alan_Ballard@mtsg.ubc.ca
University Computing Services  |   Bitnet: USERAB1@UBCMTSG
University of British Columbia |    Phone: 604-228-3074
Vancouver B.C. Canada V6R 1W5  |      Fax: 604-228-5116