atari email archive

a collection of messages sent at Atari from 1983 to 1992.

Getting a directory

(1 / 1)


Have you ever wanted to get a directory from within your VAX program? Well, I
had written an fdirectory function for PPSNET some time ago, so I extracted it
and made a C callable subroutine which you can use. From C, you call it
via:

	int fdirectory(string,length,array);
	char *string;		/* pointer to directory/filename to search */
	int length;		/* size of buffer in bytes */
	char *array;		/* pointer to buffer where directory goes */

It returns odd values if it worked ok otherwise it returns even values. If it
returns a 3, then that means your buffer wasn't big enough to hold the whole
directory, although it returns as much directory as would fit in your buffer.
The buffer contains stream data according to the following: 
	
	byte 0 - length of longest filename returned (useful if you're
		trying to format the screen to hold a given number
		of columns).
	byte 1 - code byte: 0 = filename follows, 1 = directory name
		follows
	byte 2 - length of name that follows (0 = end of list)
	byte 3-n - name
	byte n+1 - code byte
	byte n+2 - length
		...

A directory name will preceed all the filenames that appear in that directory.
There's an example program (UTL$MAC:FDIR.C) that you can look at or run by:

	$ MCR UTL$EXE:FDIR what_ever

To use it with your program, you'll need to link in UTL$OBJ:FDIRECTORY.
For example:

	$ LINK FDIR,UTL$OBJ:FDIRECTORY

Happy directorying...

ds
Message 1 of 1

Aug 13, 1987