gould@pilot.njin.net (Brian Jay Gould) (08/21/90)
I know this is lazy, but I have no intention of becoming an OS/2 programmer. Could someone please suggest a code segment that returns the first filename in a directory? I'd like to get as the return, the oldest file in the directory. No HPFS in this case. My eternal thanks to anyone who helps. -- ************************************************* * Brian Jay Gould - Professional Brain-stormer * *************************************************
prk@planet.bt.co.uk (Peter Knight) (08/21/90)
gould@pilot.njin.net (Brian Jay Gould) writes: >I know this is lazy, but I have no intention of becoming an OS/2 programmer. >Could someone please suggest a code segment that returns the first filename >in a directory? I'd like to get as the return, the oldest file in the >directory. No HPFS in this case. >My eternal thanks to anyone who helps. >-- >************************************************* >* Brian Jay Gould - Professional Brain-stormer * >************************************************* { FILEFINDBUF buf; DosFindFirst ("*.*",HDIR_SYSTEM, FILE_read_docu_for_options, &buf,sizeof(buf),1,0); printf ("%s",buf.achName); } -- This code should do the trick. Remember to do a #define INCL_DOSFILEMGR to get the right include files included. The first parameter is the file spec so you can use , for example "c:\\*.*", etc, here. For the file options, you have to decide what you want. This system call is capable of reading hiddens, etc, so you might normally use FILE_NORMAL ie files that "dir" can find. Remember, this does not return the oldest file. You cannot get this information, as if a deleted file is written over, its place may be used by a new file. Incidentally, this code is virtually identical to the MS-DOS int 21/4eh system call. Peter Knight BT Research #inlcude <std.disclaimer>