/*
 * BSD/Unix expansion library for Amiga.
 *
 * opendir() -- system independent directory code
 */

#include "dir.h"

DIR *
opendir(dirname)
   char *dirname;
{
	register DIR	*my_dir, *AllocMem(/* int, int */) ;
	struct FileLock	*Lock(/* char *, int */), *CurrentDir(/* struct FileLock * */) ;

	if ((my_dir = AllocMem(sizeof(DIR), 0)) == NULL)
		return NULL ;

	if (((my_dir->d_lock = Lock(dirname, ACCESS_READ)) == NULL)
		/* If we can't examine it */
		||  !Examine(my_dir->d_lock, &(my_dir->d_info))
		/* Or it's not a directory */
		||  (my_dir->d_info.fib_DirEntryType < 0))
	{
		FreeMem(my_dir, sizeof(DIR)) ;
		return NULL ;
	}
	return my_dir ;
}
