/*
 * ReadDir.h
 */


#ifndef readdir_h
#define readdir_h

/* We don't ever include kernel.h, but we need an error block type */
#ifndef os_error_
#define os_error_
typedef struct
{
	int  errnum;
	char errmess[252];
} os_error;
#endif


/* A block for passing results to/from ReadDir */
typedef struct
{
	char	*dir;			/* directory to catalogue */
	void	*buffer;		/* output buffer */
	int		read;			/* how many entries to *attempt* to read */
	int		start_pos;		/* where to start / continue from */
	int		buffer_size;	/* size of the buffer */
	char	*obj_spec;		/* wildcarded name to match */
} readdir_block;

typedef struct
{
	unsigned int	load;		/* load address */
	unsigned int	exec;		/* execution address */
	unsigned int	length;		/* file size */
	unsigned int	attributes;	/* file attributes */
	unsigned int	type;		/* NB: object type, NOT filetype! */
	char			filename[4];/* size unknown, followed by ALIGN */
} readdir_record;



/* Functions provided by ReadDir.a */

/* Read entries from a directory using the parameters in the block 'b'		 */
/* 'full' controls whether the buffer is filled with null terminated strings */
/* or records (as defined above).											 */
extern os_error *ReadDir( int full, readdir_block *b );

/* Simple iterators to make life that micro-bit easier */
extern readdir_record *next_record( readdir_record *current );
extern char *next_objname( char *current );


#endif
